1. 程式人生 > >配置使用Eslint的時候 版本錯誤 "eslint": "5.6.0" a different version of eslint was detected higher up in the tr

配置使用Eslint的時候 版本錯誤 "eslint": "5.6.0" a different version of eslint was detected higher up in the tr

1, 如果你也遇到下面的問題,你可以 按照命令列提示的那樣,下面這四步完成的一般就可以了,但是不排除你在執行的時候忘記下載某些依賴。

  • 【1】 刪除 package-lock.json(不是package.json) 你可以選擇 yarn.lock 或者不要,我是沒有做這步的
  • 【2】刪除 node_modules 在你的專案資料夾裡面的 node_modules
  • 【3】移除你自己下載的 eslint, 在 package.json裡面的dependencies 或者 devDependencies
  • 【4】然後再重新 npm install 使用npm存在丟包現象,所以專案中使用 yarn可能會好一點
  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your proje ct folder.
  2. Delete node_modules in your project folder.
  3. Remove “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.
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 locall         y.

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

  "eslint": "5.6.0"

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

  E:\學習檔案\React\ticket-app\node_modules\eslint (version: 5.9.0)

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

If 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 proje         ct folder.
  2. Delete node_modules in your project folder.
  3. Remove "eslint" from dependencies and/or devDependencies in the package.jso         n 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 st         eps with it instead.
     This may help because npm has known issues with package hoisting which may          get resolved in future versions.

  6. Check if E:\學習檔案\React\ticket-app\node_modules         \eslint is outside your project directory.
     For example, you might have accidentally installed something in your home f         older.

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

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your pro         ject.
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 yo         u find them helpful!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 
[email protected]
start-js: `react-scripts start` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start-js script. npm ERR! This is probably not a problem with npm. There is likely additional log ging output above. npm ERR! A complete log of this run can be found in: npm ERR! F:\nodejs\node_cache\_logs\2018-11-13T09_20_40_840Z-debug.log ERROR: "start-js" exited with 1. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start: `npm-run-all -p watch-css start-js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is probably not a problem with npm. There is likely additional log ging output above. npm ERR! A complete log of this run can be found in: npm ERR! F:\nodejs\node_cache\_logs\2018-11-13T09_20_42_191Z-debug.log

在遇到問題的時候,錯誤的提示是很重要的。終於解決了。。。