错误:
每次我尝试使用npm安装某些模块时,都会在控制台中获得以下输出日志:
1:C:\Windows\system32>npm install -g serialport
2:"CALL "C:\Users\<user>\Documents\nodejs\\node.exe"
3:"C:\Users\<user>\Documents\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g" is not recognized as an
4:internal or external command,5:programa o archivo por lotes ejecutable.
6:npm WARN registry Using stale data from https://registry.npmjs.org/ because the host is inaccessible --
7:are you offline?
8:npm WARN registry Using stale data from https://registry.npmjs.org/ due to a request error during
9:revalidation.
10:
11:> @serialport/bindings@8.0.6 install
12:C:\Users\<user>\AppData\Roaming\npm\node_modules\serialport\node_modules\@serialport\bindings
13:> prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild
14:
15:npm ERR! code ELIFECYCLE
16:npm ERR! syscall spawn C:\Windows\system32\cmd.exe;C:\Python34;
17:npm ERR! file C:\Windows\system32\cmd.exe;C:\Python34;
18:npm ERR! path C:\Windows\system32\cmd.exe;C:\Python34;
19:npm ERR! errno -4058
20:npm ERR! @serialport/bindings@8.0.6 install: `prebuild-install --tag-prefix @serialport/bindings@ ||
21:node-gyp rebuild`
22:npm ERR! spawn C:\Windows\system32\cmd.exe;C:\Python34; ENOENT
23:npm ERR!
24:npm ERR! Failed at the @serialport/bindings@8.0.6 install script.
25:npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
26:
27:npm ERR! A complete log of this run can be found in:
28:npm ERR! C:\Users\<user>\AppData\Roaming\npm-cache\_logs\2020-01-25T14_44_28_892Z-debug.log
(请注意,此输出中的行枚举是手工制作的,与实际的输出行不符。这只是为了更好地指出问题)
头灯:
- npm ERR!代码ELIFECYCLE
- npm ERR! errno -4058
- npm ERR! @ serialport / bindings @ 8.0.6安装脚本失败。
当我尝试运行命令npm install -g <module>
或什至只是npm install <module>
来执行本地操作时,会弹出此错误。
也
在 2 和 4 行之间可以看到的输出日志是我每次尝试运行npm时都会得到的 命令,无论是否为“ npm install”或任何其他命令。
示例:
C:\Windows\system32>npm -v
"CALL "C:\Users\<user>\Documents\nodejs\\node.exe" "C:\Users\<user>\Documents\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g" npm' is not recognized as an internal or external command,operable program,or batch file.
6.13.6
在此示例和上一个示例中,您可以看到:即使我收到此错误消息,该命令也会在出现此错误后执行。
其他信息
- 我已在自定义位置
C:\Users\<user>\Documents\nodejs
而非C:\Program Files\nodejs
上安装了Node.js - 以前,我在这台计算机上安装Node.js时从未遇到过这个问题。
- NPM缓存日志:https://drive.google.com/file/d/1DOd4uYVjn_ko3ZWZOM8ceavx8w_yYSWY/view?usp=sharing
-
操作系统: ----------- Windows 10
Node.js: ----- v13.7.0
NPM: --------- v6.13.6