繁体   English   中英

为什么 npm 我无法完成安装? 为什么它告诉节点和 npm 是无效命令?

[英]Why won't npm i complete the install? Why is it telling node and npm are invalid commands?

试图运行一个 React 项目。 我已经安装了最新的节点,并根据自述文件尝试了旧版本。 我已经卸载了 Node,从 APPDATA/ROAMING 和 ProgramFiles 中清除了它的所有痕迹,然后重新安装。 同事机器上有各种版本的Node和npm,可以在本地运行项目。 我检查了我的环境变量并确保正确设置了 PATH 属性。 我已经从 JSON 文件中删除了这个特定的 package 并重试并看到类似的问题。 节点和 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

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

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

希望这对你也有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM