NPM and cnpm installation failure solution

First, post the error: here is my error log:

0 info it worked if it ends with ok
1 verbose cli [ 'D:\\nodejs\\node.exe',
1 verbose cli   'D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   'cnpm',
1 verbose cli   '--registry=https://registry.npm.taobao.org' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 026191e276c3f621
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for cnpm@latest request to https://registry.npm.taobao.org/cnpm failed, reason: connect ETIMEDOUT 93.184.216.34:8080
8 timing stage:rollbackFailedOptional Completed in 1ms
9 timing stage:runTopLevelLifecycles Completed in 133469ms
10 verbose type system
11 verbose stack FetchError: request to https://registry.npm.taobao.org/cnpm failed, reason: connect ETIMEDOUT 93.184.216.34:8080
11 verbose stack     at ClientRequest.req.on.err (D:\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
11 verbose stack     at ClientRequest.emit (events.js:189:13)
11 verbose stack     at onerror (D:\nodejs\node_modules\npm\node_modules\agent-base\index.js:100:9)
11 verbose stack     at callbackError (D:\nodejs\node_modules\npm\node_modules\agent-base\index.js:122:5)
11 verbose stack     at process._tickCallback (internal/process/next_tick.js:68:7)
12 verbose cwd C:\Users\Administrator.L6BFMF7743P5SU1
13 verbose Windows_NT 10.0.17763
14 verbose argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "cnpm" "--registry=https://registry.npm.taobao.org"
15 verbose node v10.15.3
16 verbose npm  v6.4.1
17 error code ETIMEDOUT
18 error errno ETIMEDOUT
19 error network request to https://registry.npm.taobao.org/cnpm failed, reason: connect ETIMEDOUT 93.184.216.34:8080
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 ]

Installed many times, are the same error, the installation of online solutions to try a lot of unresolved. Later, according to the log, it was found that it was the agent setting problem.

At first, I thought that the Taobao agent was not effective. Later, when I installed cnpm, I found the same problem, but it was not the problem of Taobao setting.

Note the proxy address printed in the log: 93.184.216.34:8080.

Solution: set the above address and port as proxy

Step one:

npm config set prefix "D:\nodejs\node_global"

Step 2:

npm config set cache "D:\nodejs\node_cache"

Step 3:

npm config set proxy 93.184.216.34:8080

Step 4:

npm config set https-proxy 93.184.216.34:8080

last:

npm install -g cnpm --registry=https://registry.npm.taobao.org

After the above execution, you can enter: cnpm – V to test

 
Refer to node for specific installation process . JS installation and cnpm configuration

Reference article: NPM and cnpm (Windows) installation steps

                   npm ERR ! network connect ETIMEDOUT

Read More: