1. 程式人生 > >npm install stylus --save失敗

npm install stylus --save失敗

下面是日誌檔案

0 info it worked if it ends with ok
1 verbose cli [ 'F:\\Install\\web\\nodejsInstall\\node.exe',
1 verbose cli   'F:\\Install\\web\\nodejsInstall\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'stylus',
1 verbose cli   '--save' ]
2 info using [email protected]
3 info using [email protected] 4 verbose npm-session 8d66494b927eb577 5 silly install loadCurrentTree 6 silly install readLocalPackageData 7 silly fetchPackageMetaData error for [email protected] request to https://registry.npmjs.org/stylus failed, reason: connect ETIMEDOUT 104.16.26.35:443 8 timing stage:rollbackFailedOptional Completed in 1ms 9 timing stage:runTopLevelLifecycles Completed in 150342ms 10 verbose type system 11 verbose stack FetchError: request to https://registry.npmjs.org/stylus failed, reason: connect ETIMEDOUT 104.16.26.35:443 11 verbose stack at ClientRequest.req.on.err (F:\Install\web\nodejsInstall\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14) 11 verbose stack at ClientRequest.emit (events.js:182:13) 11 verbose stack at TLSSocket.socketErrorListener (_http_client.js:391:9) 11 verbose stack at TLSSocket.emit (events.js:182:13) 11 verbose stack at emitErrorNT (internal/streams/destroy.js:82:8) 11 verbose stack at emitErrorAndCloseNT (internal/streams/destroy.js:50:3) 11 verbose stack at process._tickCallback (internal/process/next_tick.js:63:19) 12 verbose cwd F:\Install\CompilerWorkspace\WebStorm\travel\travel\travel 13 verbose Windows_NT 10.0.17134 14 verbose argv "F:\\Install\\web\\nodejsInstall\\node.exe" "F:\\Install\\web\\nodejsInstall\\node_modules\\npm\\bin\\npm-cli.js" "install" "stylus" "--save" 15 verbose node v10.12.0 16 verbose npm v6.4.1 17 error code ETIMEDOUT 18 error errno ETIMEDOUT 19 error network request to https://registry.npmjs.org/stylus failed, reason: connect ETIMEDOUT 104.16.26.35:443 20 error network This is a problem related to network connectivity. 20 error network In most cases you are behind a proxy or have bad network settings. 20 error network 20 error network If you are behind a proxy, please make sure that the 20 error network 'proxy' config is set properly. See: 'npm help config' 21 verbose exit [ 1, true ]

解決方法:

使用映象 ,在 .npmrc 加入下面內容

registry = http://registry.cnpmjs.org

.npmrc 一般在 C 盤的 user 資料夾