安装react-router-dom后,Web应用程序启动时会在终端中显示shpws错误

时间:2019-03-16 10:20:48

标签: reactjs npm

我正在尝试创建reactjs应用,每次安装react-router-dom时,当我执行npm start时,Web应用都会在终端中显示错误。

这是错误

sh: 1: react-scripts: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! routeroute@0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the routeroute@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!     /home/rock/.npm/_logs/2019-03-16T10_04_47_549Z-debug.log

我尝试执行rm -rf node_modules,然后再次安装,但似乎无法正常工作。 当我再次安装npm时, 我收到此错误

npm ERR! path /home/rock/Desktop/routeroute/node_modules/browserslist/cli.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/home/rock/Desktop/routeroute/node_modules/browserslist/cli.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/rock/.npm/_logs/2019-03-16T10_19_02_250Z-debug.log

这是package.json的依赖项

  {
  "name": "routeroute",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.8.4",
    "react-dom": "^16.8.4",
    "react-router-dom": "^4.4.0",
    "react-scripts": "2.1.8"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

1 个答案:

答案 0 :(得分:0)

您需要更新您的npm版本:

  1. 尝试使用以下命令: npm i -g npm

  2. 或者您可以使用以下命令: npm install npm @ latest -g