一、问题描述
执行 npm install 报错:
npm install
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chromedriver@2.46.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chromedriver@2.46.0 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! /root/.npm/_logs/2022-05-10T06_59_57_899Z-debug.log
二、解决方法
1.方法1
vue-cli 脚手架的一个 bug,原因是 chromedriver 的部分文件被国内网络给墙掉了,执行以下命令:
npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
2.方法2
方法1不行的话尝试方法2:
sudo npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
此时会提示找不到命令,执行以下操作:
sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
3.方法3
如果以上方法都不行,尝试方法3:
npm install --ignore-scripts
npm install
版权声明:本文为u012069313原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。