首页 > 解决方案 > NPM 模块安装错误“代码 ELIFECYCLE”“errno 4058”

问题描述

错误:

每次我尝试使用 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 错误!代码生命周期
  • npm 错误!错误号 -4058
  • npm 错误!@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

正如您在此示例和上一个示例中所看到的:即使我收到此错误消息,该命令仍会在所述错误之后执行。


额外信息

标签: javascriptnode.jswindowsnpmnode-modules

解决方案


推荐阅读