cloudstuido 使用問題

執(zhí)行cnpm install 后報錯

[npminstall:runscript:error] chromedriver@^2.27.2 scripts.install run "node install.js" error: RunScriptError: Run "sh -c node install.js" error, exit code null
? Install fail! RunScriptError: post install error, please remove node_modules before retry!
Run "sh -c node install.js" error, exit code null
RunScriptError: post install error, please remove node_modules before retry!
Run "sh -c node install.js" error, exit code null
    at ChildProcess.proc.on.code (/usr/lib/node_modules/cnpm/node_modules/runscript/index.js:96:21)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
npminstall version: 3.27.0
npminstall args: /usr/bin/node /usr/lib/node_modules/cnpm/node_modules/npminstall/bin/install.js --fix-bug-versions --china --userconfig=/root/.cnpmrc --disturl=https://npm.taobao.org/mirrors/node --registry=https://r.npm.taobao.org
image.png

查了好多方法都沒用,后處理如下
1.如果執(zhí)行過npm install,先刪除 node_modules 文件夾,不然運行的時候可能會報錯
2.執(zhí)行下面的命令

npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver

3.再執(zhí)行 npm install 即可正常下載

問題原因
經(jīng)分析發(fā)現(xiàn),某些版本下,chromedriver 的 zip 文件 url 的響應是 302 跳轉(zhuǎn),而在 install.js 里使用的是 Node.js 內(nèi)置的 http 對象的 get 方法無法處理 302 跳轉(zhuǎn)的情況;而在另外一些情況下,則是因為 googleapis.com 被墻了,此時即使采用科學 上網(wǎng)的方法也仍然無法獲取文件。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容