运行 npm start 时 Babelloader 多个版本错误
Babelloader multiple versions error when running npm start
Npm 安装在我使用 MacOS 的机器上,在我 运行 npm run start
或 npm start
.
There might be a problem with the project dependency tree.
[0] It is likely not a bug in Create React App, but something you need to fix locally.
[0]
[0] The react-scripts package provided by Create React App requires a dependency:
[0]
[0] "babel-loader": "8.0.6"
[0]
[0] Don't try to install it manually: your package manager does it automatically.
[0] However, a different version of babel-loader was detected higher up in the tree:
[0]
[0] /Users/user1/node_modules/babel-loader (version: 8.1.0)
[0]
[0] Manually installing incompatible versions is known to cause hard-to-debug issues.
如果是 Babel-Loader 问题,我将其删除,然后当我 运行:
npm ls babel-loader
它仍然存在,返回这个:
react-scripts@3.4.0
└── babel-loader@8.0.6
Babel-loader 未在 package.json 文件中列出。我真的不确定如何完全卸载babel-loader,如果我不确定是否需要重新安装它。
根据根本原因,您有两种可能的方法。默认答案是删除您的锁定文件和 node_modules 文件夹,然后重新生成锁定文件。
$ rm package-lock.json # or `rm yarn.lock`
$ rm -rf node_modules/
$ npm install # or `yarn install`
这并不总是有效。如果问题仍然存在,请执行以下操作。
$ npm ls babel-loader # or `yarn list babel-loader`
warning Lockfile has incorrect entry for "babel-loader@^<bad-version>". Ignoring it.
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ babel-loader@<bad-version>
└─ react-scripts@4.0.3
└─ babel-loader@<good-version>
✨ Done in 1.17s.
完成后,打开 package.json
并添加以下内容:
{
// ...
"resolutions": {
"babel-loader": "<good-version>"
}
}
Npm 安装在我使用 MacOS 的机器上,在我 运行 npm run start
或 npm start
.
There might be a problem with the project dependency tree.
[0] It is likely not a bug in Create React App, but something you need to fix locally.
[0]
[0] The react-scripts package provided by Create React App requires a dependency:
[0]
[0] "babel-loader": "8.0.6"
[0]
[0] Don't try to install it manually: your package manager does it automatically.
[0] However, a different version of babel-loader was detected higher up in the tree:
[0]
[0] /Users/user1/node_modules/babel-loader (version: 8.1.0)
[0]
[0] Manually installing incompatible versions is known to cause hard-to-debug issues.
如果是 Babel-Loader 问题,我将其删除,然后当我 运行:
npm ls babel-loader
它仍然存在,返回这个:
react-scripts@3.4.0
└── babel-loader@8.0.6
Babel-loader 未在 package.json 文件中列出。我真的不确定如何完全卸载babel-loader,如果我不确定是否需要重新安装它。
根据根本原因,您有两种可能的方法。默认答案是删除您的锁定文件和 node_modules 文件夹,然后重新生成锁定文件。
$ rm package-lock.json # or `rm yarn.lock`
$ rm -rf node_modules/
$ npm install # or `yarn install`
这并不总是有效。如果问题仍然存在,请执行以下操作。
$ npm ls babel-loader # or `yarn list babel-loader`
warning Lockfile has incorrect entry for "babel-loader@^<bad-version>". Ignoring it.
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ babel-loader@<bad-version>
└─ react-scripts@4.0.3
└─ babel-loader@<good-version>
✨ Done in 1.17s.
完成后,打开 package.json
并添加以下内容:
{
// ...
"resolutions": {
"babel-loader": "<good-version>"
}
}