簡體   English   中英

npm start 顯示 babel-eslint 版本存在問題

[英]npm start is showing an issue with babel-eslint version

當我運行 npm 啟動命令為使用 npx create-react-app my-app 創建的我的反應應用程序啟動服務器時,發生以下錯誤。請幫助我解決以下錯誤。我也嘗試了所有步驟它在下面提到,但錯誤未清除。

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "babel-eslint": "10.1.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-eslint was detected higher up in the tree:

  C:\Users\LENOVO\node_modules\babel-eslint (version: 9.0.0) 

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if C:\Users\LENOVO\node_modules\babel-eslint is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls babel-eslint in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed babel-eslint.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactapp@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactapp@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\LENOVO\AppData\Roaming\npm-cache\_logs\2020-07-19T12_53_40_050Z-debug.log

在 Desktop 文件夾之外創建您的應用程序。

這是因為 package 版本安裝在用戶目錄中。 錯誤中的行提到了全局用戶目錄中的覆蓋版本。

C:\Users\LENOVO\node_modules\babel-eslint(版本:9.0.0)

嘗試更新用戶目錄中 node_modules 文件夾中的版本或刪除這些版本並根據每個項目要求維護本地 node_modules。

我找到了一個可能的解決方案,或者至少這個對我來說效果很好。 npm install @babel/eslint-parser然后npm start 如果這不起作用,請先嘗試以下操作:

  • 刪除節點模塊中的 babel-eslint 或
  • npm ls babel-eslint搜索你可以找到那個的地方,

我希望對你有用。 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM