npm start在WebStorm上的React app中产生错误

问题描述 投票:0回答:3

我之前已经问过这个问题,但没有一个解决方案似乎对我有帮助。

我得到的错误,我试图删除node_modules目录。然后重新安装npm。还是一样的错误。

  1. rm -rf node_modules
  2. npm install
  3. npm start - 同样的错误

甚至尝试删除package-lock.json,但在npm启动时出现相同的错误。

节点版本 - v10.15.3 NPM版本 - 6.4.1

Aryans-MacBook-Pro:react-new-app aryanarora$ npm start

> [email protected] start /Users/aryanarora/Desktop/The Web Developer Bootcamp/01 All Practice Files /js<:>/Jon Duckett/react-new-app
> react-scripts start

sh: react-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] start: `react-scripts start`
npm ERR! spawn ENOENT
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 logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/aryanarora/.npm/_logs/2019-04-29T06_08_07_273Z-debug.log

npm list --depth 0 | grep react-scripts输出后如下:

Aryans-MacBook-Pro:react-new-app aryanarora$ npm list --depth 0 | grep react-scripts
└── [email protected]
npm ERR! peer dep missing: typescript@*, required by @typescript-eslint/[email protected]
npm ERR! peer dep missing: typescript@*, required by @typescript-eslint/[email protected]
npm ERR! peer dep missing: typescript@*, required by @typescript-eslint/[email protected]
npm ERR! peer dep missing: typescript@*, required by @typescript-eslint/[email protected]
npm ERR! peer dep missing: typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev, required by [email protected]
npm ERR! peer dep missing: typescript@*, required by @typescript-eslint/[email protected]
npm ERR! peer dep missing: typescript@*, required by [email protected]

Package.json文件

{
  "name": "react-new-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-scripts": "3.0.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
reactjs webstorm
3个回答
0
投票

请确保安装了React-scripts节点模块,为了检查这一点,请执行以下步骤。

  • 再次安装npm install
  • 转到node_modules - > react-scripts(确保文件夹存在)
  • 运行npm start

0
投票

这可能是npm版本的问题。请尝试一些建议。

  1. 卸载纱线npm uninstall -g yarn
  2. 缓存清理。 npm cache clean -f
  3. 如果仍然无效,请尝试将npm版本降级/升级到npm 5.4.2或npm 5.3。*。 npm install -g [email protected]

0
投票

问题可能是节点和npm本身。尝试使用Homebrew或NVM完全从您的计算机上卸载节点,无论您使用哪个安装节点。否则你必须手动完成。

按照此链接中的步骤 - https://stackabuse.com/how-to-uninstall-node-js-from-mac-osx/

接下来从官方网站(https://nodejs.org/en/)安装LTS节点,这应该可以解决问题。

我发现有用的一件事是更改目录。我的目录有一个名为“</>js”的文件夹,我相信它创建了一些问题。

© www.soinside.com 2019 - 2024. All rights reserved.