我看到之前曾有人问过这个问题,但似乎没有一个解决方案对我有帮助。
我遇到的错误,我也尝试删除了node_modules
目录。然后重新安装npm。还是一样的错误。
rm -rf node_modules
npm install
npm start
-同样的错误甚至尝试删除package-lock.json
,但在npm启动时出现相同的错误。
节点版本-v10.15.3
NPM版本-6.4.1
Aryans-MacBook-Pro:react-new-app aryanarora$ npm start
> react-new-app@0.1.0 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! react-new-app@0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the react-new-app@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! /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
└── react-scripts@3.0.0
npm ERR! peer dep missing: typescript@*, required by @typescript-eslint/eslint-plugin@1.6.0
npm ERR! peer dep missing: typescript@*, required by @typescript-eslint/parser@1.6.0
npm ERR! peer dep missing: typescript@*, required by @typescript-eslint/parser@1.6.0
npm ERR! peer dep missing: typescript@*, required by @typescript-eslint/typescript-estree@1.6.0
npm ERR! peer dep missing: typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev, required by tsutils@3.10.0
npm ERR! peer dep missing: typescript@*, required by @typescript-eslint/typescript-estree@1.6.0
npm ERR! peer dep missing: typescript@*, required by ts-pnp@1.1.2
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"
]
}
}
答案 0 :(得分:0)
请确保已安装React-scripts
节点模块,要进行检查,请执行以下步骤。
npm install
npm start
答案 1 :(得分:0)
这可能是npm版本的问题。请尝试一些建议。
npm uninstall -g yarn
npm cache clean -f
如果仍然无法运行,请尝试将npm版本降级/升级到npm 5.4.2或npm 5.3。*。
npm install -g npm@5.4.2
答案 2 :(得分:0)
问题可能出在节点和npm本身。 尝试使用Homebrew或NVM从计算机上完全卸载节点,无论使用哪种方式来安装节点。否则,您必须手动进行操作。
按照此链接中的步骤操作-https://stackabuse.com/how-to-uninstall-node-js-from-mac-osx/
接下来从官方网站(https://nodejs.org/en/)安装LTS节点,这应该可以解决问题。
我还发现有帮助的一件事是更改目录。我的目录中有一个名为“ </>js
”的文件夹,我相信这会造成一些问题。