我看到以前有人问过这个问题,但似乎没有一个解决方案对我有帮助。
我收到的错误,我也尝试删除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
包.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"
]
}
}
请确保安装了React-scripts
节点模块,要检查这一点,请执行以下步骤。
- 再次安装
npm install
- 转到node_modules --> 反应脚本(确保文件夹存在(
- 运行
npm start
这可能是npm版本的问题。请尝试一些建议。
-
卸载纱线
npm uninstall -g yarn
-
执行缓存清理。
npm cache clean -f
-
如果仍然不起作用,请尝试将您的 npm 版本降级/升级到 npm 5.4.2 或 npm 5.3.*。
npm install -g npm@5.4.2
问题可能是节点和 npm 本身。尝试使用 Homebrew 或 NVM(以用于安装节点为准(从计算机中完全卸载节点。否则,您必须手动执行此操作。
按照此链接中的步骤 - https://stackabuse.com/how-to-uninstall-node-js-from-mac-osx/
接下来从官方网站(https://nodejs.org/en/(安装LTS节点,这应该可以解决问题。
我还发现有帮助的一件事是更改目录。我的目录有名为" </>js
"的文件夹,我相信这造成了一些问题。