Npm是使用MacOS安装在我的计算机上的,运行ELIFECYCLE
或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
package.json文件中未列出Babel-loader。我真的不确定如何完全卸载babel-loader,如果不确定是否需要再次重新安装,则不知道。
答案 0 :(得分:0)
根据根本原因,您有两种可能的方法。默认的答案是删除你的锁文件和 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>"
}
}