首页 > 解决方案 > npm run dev 函数在我的 ubuntu 操作系统中出现错误

问题描述

当我运行npm run dev函数时,它给了我这个,就在一天前它工作正常,有人可以帮助我为什么会出现这个错误吗?这是我的完整错误回复,任何人都可以看看这个回复,并帮助我其中的确切问题是什么?任何帮助将不胜感激,我花了很多时间来解决这个问题,但没有帮助我,

> mern-auth@1.0.0 dev /var/www/mern-plaid
> concurrently "npm run server" "npm run client"
[0] 
[0] > mern-auth@1.0.0 server /var/www/mern-plaid
[0] > nodemon server.js
[0] 
[1] 
[1] > mern-auth@1.0.0 client /var/www/mern-plaid
[1] > npm start --prefix client
[1] 
[0] [nodemon] 1.19.1
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching: *.*
[0] [nodemon] starting `node server.js`
[1] 
[1] > client@0.1.0 start /var/www/mern-plaid/client
[1] > react-scripts start
[1] 
[1] 
[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]   "babel-eslint": "9.0.0"
[1] 
[1] Don't try to install it manually: your package manager does it automatically.
[1] However, a different version of babel-eslint was detected higher up in the tree:
[1] 
[1]   /var/www/mern-plaid/client/node_modules/babel-eslint (version: 10.0.3) 
[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 "babel-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 /var/www/mern-plaid/client/node_modules/babel-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 babel-eslint in your project folder.
[1]      This will tell you which other package (apart from the expected react-scripts) installed babel-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] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1
[1] npm ERR! client@0.1.0 start: `react-scripts start`
[1] npm ERR! Exit status 1
npm ERR! 
[1] npm ERR! Failed at the client@0.1.0 start script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[0] Server up and running on port 5000 !
[1] 
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR!     /root/.npm/_logs/2019-08-26T10_33_27_229Z-debug.log
[1] npm ERR! code ELIFECYCLE
npm ERR! errno 1
[1] npm ERR! mern-auth@1.0.0 client: `npm start --prefix client`
[1] npm ERR! Exit status 1
npm ERR! 
[1] npm ERR! Failed at the mern-auth@1.0.0 client script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[1] 
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR!     /root/.npm/_logs/2019-08-26T10_33_27_278Z-debug.log
[1] npm run client exited with code 1
[0] MongoDB successfully connected

包.json

{
  "name": "mern-auth",
  "version": "1.0.0",
  "description": "Mern Auth Example",
  "main": "server.js",
  "scripts": {
    "client-install": "npm install --prefix client",
    "start": "node server.js",
    "server": "nodemon server.js",
    "client": "npm start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\""
  },
  "author": "",
  "license": "MIT",
  "dependencies": {
    "babel-eslint": "^10.0.3",
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.18.3",
    "concurrently": "^4.0.1",
    "express": "^4.16.4",
    "is-empty": "^1.2.0",
    "jsonwebtoken": "^8.3.0",
    "moment": "^2.24.0",
    "mongoose": "^5.3.11",
    "nodemon": "^1.19.1",
    "passport": "^0.4.0",
    "passport-jwt": "^4.0.0",
    "plaid": "^4.2.0",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-scripts": "^3.1.1",
    "validator": "^10.9.0"
  }
}

标签: node.jsreactjsnpmnode-modules

解决方案


在 npm 中,如果您知道所需包的确切版本 y,您可以将其附加到包名称的 @ 字符之后。

在您的情况下,react 需要 9.0.0 的版本,因此,您需要卸载 babel-eslint v. 10.0.3 并安装 v. 9.0.0。

npm uninstall babel-eslint --save
npm install --save babel-eslint@9.0.0

推荐阅读