1. 程式人生 > >Mac下安裝cordova-hot-code-push-cli失敗

Mac下安裝cordova-hot-code-push-cli失敗

Mac下安裝cordova-hot-code-push-cli失敗,執行命令為:sudo npm i -g cordova-hot-code-push-cli

具體錯誤日誌如下:

npm WARN deprecated [email protected]: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
npm WARN deprecated 
[email protected]
: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN deprecated [email protected]: renamed to d3-queue /Users/xxx/.npm-global/bin/cordova-hcp -> /Users/shanon/.npm-global/lib/node_modules/cordova-hot-code-push-cli/bin/cordova-hcp > [email protected]
postinstall /Users/xxx/.npm-global/lib/node_modules/cordova-hot-code-push-cli/node_modules/ngrok > node ./postinstall.js ngrok - unpacking binary ngrok - error unpacking binary { Error: EACCES: permission denied, open '/Users/xxx/.npm-global/lib/node_modules/cordova-hot-code-push-cli/node_modules/ngrok/bin/ngrok' errno: -13, code: 'EACCES', syscall: 'open', path: '/Users/shanon/.npm-global/lib/node_modules/cordova-hot-code-push-cli/node_modules/ngrok/bin/ngrok' } ngrok - install failed, retrying ngrok - downloading binary https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-amd64.zip ngrok - error storing binary to local file { Error: EACCES: permission denied, open '/Users/xxx/.ngrok/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1kYXJ3aW4tYW1kNjQuemlw.zip' errno: -13, code: 'EACCES', syscall: 'open', path: '/Users/xxx/.ngrok/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1kYXJ3aW4tYW1kNjQuemlw.zip' } ngrok - install failed, retrying ngrok - downloading binary https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-amd64.zip ngrok - error storing binary to local file { Error: EACCES: permission denied, open '/Users/xxx/.ngrok/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1kYXJ3aW4tYW1kNjQuemlw.zip' errno: -13, code: 'EACCES', syscall: 'open', path: '/Users/shanon/.ngrok/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1kYXJ3aW4tYW1kNjQuemlw.zip' } ngrok - install failed { Error: EACCES: permission denied, open '/Users/xxx/.ngrok/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1kYXJ3aW4tYW1kNjQuemlw.zip' errno: -13, code: 'EACCES', syscall: 'open', path: '/Users/xxx/.ngrok/aHR0cHM6Ly9iaW4uZXF1aW5veC5pby9jLzRWbUR6QTdpYUhiL25ncm9rLXN0YWJsZS1kYXJ3aW4tYW1kNjQuemlw.zip' } npm WARN
[email protected]
requires a peer of [email protected]~1.4.0 but none is installed. You must install peer dependencies yourself. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] postinstall: `node ./postinstall.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] postinstall 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! /Users/shanon/.npm/_logs/2019-01-08T04_03_05_057Z-debug.log

錯誤提示顯示permission問題,然後安裝ngrok失敗,嘗試各種方式,其實還是許可權不夠的問題,顯示簡介給了許可權也沒用。

最後翻閱各種帖子,我的解決方式如下:

npm config set unsafe-perm=true

執行該語句後,再執行上面的安裝命令,居然成功了。

另外有些情況用如下方式也能解決,此處記錄一下;

sudo npm i -g ngrok --unsafe-perm=true --allow-root