npm install时,报错 install: `node install.js`安装失败

本文介绍了解决在执行npm install命令时遇到的phantomjs-prebuilt安装错误的方法,建议使用--ignore-scripts参数来跳过出错的脚本。

在执行 npm install时,出现如下错误

npm ERR! phantomjs-prebuilt@2.1.14 install: `node install.js`
 
npm ERR! Exit status 1
 
npm ERR!
 
npm ERR! Failed at the phantomjs-prebuilt@2.1.14 install script 'node install.js

应该在命令后加参数 --ignore-scripts

npm install --ignore-scripts
在 Vue 项目中使用 `npm install --save xlsx` 安装 `xlsx` 包,如果提示连接到淘宝 NPM 镜像(如 `https://registry.npm.taobao.org/xlsx`)并报错,通常是由于当前使用的 NPM 镜像源配置问题或网络问题导致的。以下是解决该问题的几种方法: ### 1. 切换回官方 NPM 源 淘宝 NPM 镜像在某些情况下可能会出现证书过期或连接问题。可以尝试将 NPM 源切换回官方源: ```bash npm config set registry https://registry.npmjs.org/ ``` 然后再次运行安装命令: ```bash npm install --save xlsx ``` ### 2. 使用 `nrm` 管理镜像源 如果经常需要切换 NPM 镜像源,可以使用 `nrm` 工具进行管理。首先安装 `nrm`: ```bash npm install -g nrm ``` 然后查看可用的镜像源: ```bash nrm ls ``` 输出可能如下: ``` npm -------- https://registry.npmjs.org/ yarn ------- https://registry.yarnpkg.com/ cnpm ------- http://r.cnpmjs.org/ * taobao ----- https://registry.npm.taobao.org/ nj --------- https://registry.nodejitsu.com/ npmMirror -- https://skimdb.npmjs.com/registry/ edunpm ----- http://registry.enpmjs.org/ ``` 切换到官方源或其他可用源: ```bash nrm use npm ``` 再尝试安装 `xlsx` 包。 ### 3. 忽略 SSL 证书错误(不推荐) 如果确认网络环境安全,但遇到证书过期问题,可以临忽略 SSL 证书验证: ```bash npm config set strict-ssl false ``` 安装完成后建议恢复默认设置: ```bash npm config set strict-ssl true ``` ### 4. 使用 `--registry` 参数指定源 可以在安装命令中直接指定使用官方源: ```bash npm install --save xlsx --registry=https://registry.npmjs.org/ ``` ### 5. 更新 Node.js 和 NPM 如果使用的是较旧版本的 Node.js 或 NPM,可能会导致与某些包的兼容性问题。建议升级到最新稳定版本。 ### 6. 清除 NPM 缓存 有缓存中的损坏数据也会导致安装失败,可以尝试清除 NPM 缓存: ```bash npm cache clean --force ``` 再重新安装 `xlsx` 包。 ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值