为什么 npm i 不能完成安装?为什么它告诉 node 和 npm 是无效命令?

时间:2021-03-18 22:11:42

标签: node.js npm

尝试运行一个 React 项目。我已经安装了最新的节点,并根据自述文件尝试了旧版本。我已经卸载了 Node,从 APPDATA/ROAMING 和 ProgramFiles 中清除了它的所有痕迹,然后重新安装。同事在他们的机器上有各种版本的Node和npm,并且能够在本地运行项目。我已经检查了我的环境变量并确保正确设置了 PATH 属性。我已经从 JSON 文件中删除了这个特定的包,并重试并看到了类似的问题。 Node 和 npm 已经明确安装了。有没有人遇到过这种情况或有尝试的建议?我已经为此工作了好几天了!谢谢。

PS C:\dev\NAE\become-react-app> node --version
v14.16.0
PS C:\dev\NAE\become-react-app> npm -v
6.14.11
PS C:\dev\NAE\become-react-app> npm i

> @newrelic/native-metrics@5.0.0 install C:\dev\NAE\become-react-app\node_modules\@newrelic\native-metrics
> node ./lib/pre-build.js install native_metrics

'node' is not recognized as an internal or external command,
operable program or batch file.

> husky@4.2.3 install C:\dev\NAE\become-react-app\node_modules\husky
> node husky install

'node' is not recognized as an internal or external command,
operable program or batch file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\react-scripts\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\react-scripts\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\nodemon\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @newrelic/native-metrics@5.0.0 (node_modules\@newrelic\native-metrics):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @newrelic/native-metrics@5.0.0 install: `node ./lib/pre-build.js install native_metrics`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! husky@4.2.3 install: `node husky install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the husky@4.2.3 install 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!     C:\Users\ngmoscho\AppData\Roaming\npm-cache\_logs\2021-03-18T21_32_55_714Z-debug.log
PS C:\dev\NAE\become-react-app> npm run start:local

> become-react-app@1.1.0 prestart:local C:\dev\NAE\become-react-app
> npm run makeLocalEnv

'npm' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! become-react-app@1.1.0 prestart:local: `npm run makeLocalEnv`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the become-react-app@1.1.0 prestart:local 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!     C:\Users\ngmoscho\AppData\Roaming\npm-cache\_logs\2021-03-18T22_08_46_897Z-debug.log

2 个答案:

答案 0 :(得分:0)

我会再次尝试重新安装 Node!

答案 1 :(得分:0)

我曾经在它似乎已安装的地方安装过它,但在执行命令时却没有。就像你一样。即使在重新安装 npm 和 node 之后,结果还是一样。 我重新启动了我的计算机,这为我解决了问题。 相当蹩脚的解决方案,我花了一段时间才找到。

希望这对您也有帮助。