我正在使用create-react-app(Reactv16.12.0)。当我在Mac上运行'npm start'
时,我得到以下错误。
[1] There might be a problem with the project dependency tree.
[1] It is likely not a bug in Create React App, but something you need to fix locally.
[1]
[1] The react-scripts package provided by Create React App requires a dependency:
[1]
[1] "eslint": "^6.6.0"
[1]
[1] Don't try to install it manually: your package manager does it automatically.
[1] However, a different version of eslint was detected higher up in the tree:
[1]
[1] /Users/abz/node_modules/eslint (version: 6.5.1)
[1]
[1] Manually installing incompatible versions is known to cause hard-to-debug issues.
[1]
[1] If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
[1] That will permanently disable this message but you might encounter other issues.
[1]
[1] To fix the dependency tree, try following the steps below in the exact order:
[1]
[1] 1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
[1] 2. Delete node_modules in your project folder.
[1] 3. Remove "eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
[1] 4. Run npm install or yarn, depending on the package manager you use.
[1]
[1] In most cases, this should be enough to fix the problem.
[1] If this has not helped, there are a few other things you can try:
[1]
[1] 5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
[1] This may help because npm has known issues with package hoisting which may get resolved in future versions.
[1]
[1] 6. Check if /Users/abz/node_modules/eslint is outside your project directory.
[1] For example, you might have accidentally installed something in your home folder.
[1]
[1] 7. Try running npm ls eslint in your project folder.
[1] This will tell you which other package (apart from the expected react-scripts) installed eslint.
[1]
[1] If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
[1] That would permanently disable this preflight check in case you want to proceed anyway.
[1]
[1] P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
[1]
[1] react-scripts start exited with code 1
我搜索了一下发现
- 许多人建议的解决方案
- 从
users/abz/node_modules/
文件夹中删除eslint and babel-eslint
- 从本地项目中删除
package.json-lock, node_modules
- 运行
npm install
和npm start
我试过了,但这个解决方案不适合我。 - 此问题可以通过使用
adding an `.env file` in root folder with statement `SKIP_PREFLIGHT_CHECK=true`
但是,这不是此问题的解决方案。
有什么帮助吗?
8条答案
按热度按时间hc8w905p1#
这是因为在父级安装了一个版本不同的依赖项。在您的示例中,依赖项是
/Users/abz/node_modules/eslint
。只需从root运行此命令这应该能解决你的问题
blpfk2vs2#
以下Anuj shah和SHAHBAZ的回复:
npm install -g npm@latest
npm install -g npm@latest
个或者只做
npm i -S fsevents
已解决此问题。
但是每当我安装另一个软件包的时候,我都要一次又一次地做上面的步骤。这太令人沮丧了...
有人有更好的解决办法吗?
ghhkc1vu3#
我已经完成了以下步骤并解决了问题...
1.删除node_modules、package-lock. json/Yarn.锁
1.添加“eslint”:“^6.6.0”到您的设备依赖项
1.运行npm安装/Yarn
1.运行eslint --init命令
1.安装您需要的eslint插件
9lowa7mx4#
在我的C盘的根目录下,我找到并删除了node_modules文件夹,因为有人指出这个文件夹中存放的eslint-lint与我的项目中的文件夹冲突。
mspsb9vt5#
您正在使用多个不同版本的react-script。请更新它们以使用相同的版本,这样应该可以解决您的问题
tkclm6bt6#
刚跑完
或
https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md
y3bcpkx17#
这对我很有效npm安装--保存--保存-确切的React脚本@最新--强制
ccgok5k58#
刚跑:
错误就会消失。
npm uninstall -g eslint
在我的情况下不起作用 *