javascript - 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
正如您在此示例和上一个示例中所看到的:即使我收到此错误消息,该命令仍会在所述错误之后执行。
额外信息
- 我已将 Node.js 安装在自定义位置
C:\Users\<user>\Documents\nodejs
而不是C:\Program Files\nodejs
- 当我之前在这台计算机上安装 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
解决方案
推荐阅读
- python - 如何在 Python 中创建和遍历决策树
- java - 访问另一个类中的树形图并遍历项目
- redis - 如何扩展 Redis 队列
- python - 根据另一列中的值选择组
- android - 我应该如何连接 Room、LiveData 和 ContentProvider?
- python-2.7 - Django API 调用有时返回 404 错误,多次返回 200 ok 。URL 存在于应用程序中
- ios - 使用 self.navigationController?.pushViewController(newViewController, animated: true) 的问题
- ruby-on-rails - 铁路状态机不适用于一种状态
- mysql-8.0 - 如何在 mysql 8 中授予前缀通配符名称的所有权限
- sql-server - 在 MERGE SQL 查询中遇到问题