解决方法:
输入 npm install socket.io 前,先执行下面
npm config set proxy "http://yourip:port"

生产的npm-debug.log文件内容是:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'socket.io' ]
2 info using [email protected]
3 info using [email protected]
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData socket.io
8 silly fetchNamedPackageData socket.io
9 silly mapToRegistry name socket.io
10 silly mapToRegistry using default registry
11 silly mapToRegistry registry https://registry.npmjs.org/
12 silly mapToRegistry data Result {
12 silly mapToRegistry raw: 'socket.io',
12 silly mapToRegistry scope: null,
12 silly mapToRegistry escapedName: 'socket.io',
12 silly mapToRegistry name: 'socket.io',
12 silly mapToRegistry rawSpec: '',
12 silly mapToRegistry spec: 'latest',
12 silly mapToRegistry type: 'tag' }
13 silly mapToRegistry uri https://registry.npmjs.org/socket.io
14 verbose request uri https://registry.npmjs.org/socket.io
15 verbose request no auth needed
16 info attempt registry request try #1 at 14:51:13
17 verbose request id 9c19f6d05624ed4f
18 http request GET https://registry.npmjs.org/socket.io
19 info retry will retry, error on last attempt: Error: connect ETIMEDOUT 151.101.88.162:443
20 info attempt registry request try #2 at 14:51:44
21 http request GET https://registry.npmjs.org/socket.io
22 info retry will retry, error on last attempt: Error: connect ETIMEDOUT 151.101.88.162:443
23 info attempt registry request try #3 at 14:53:05
24 http request GET https://registry.npmjs.org/socket.io
25 silly fetchPackageMetaData Error: connect ETIMEDOUT 151.101.88.162:443
25 silly fetchPackageMetaData at Object.exports._errnoException (util.js:1026:11)
25 silly fetchPackageMetaData at exports._exceptionWithHostPort (util.js:1049:20)
25 silly fetchPackageMetaData at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
25 silly fetchPackageMetaData error for socket.io { Error: connect ETIMEDOUT 151.101.88.162:443
25 silly fetchPackageMetaData at Object.exports._errnoException (util.js:1026:11)
25 silly fetchPackageMetaData at exports._exceptionWithHostPort (util.js:1049:20)
25 silly fetchPackageMetaData at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
25 silly fetchPackageMetaData code: 'ETIMEDOUT',
25 silly fetchPackageMetaData errno: 'ETIMEDOUT',
25 silly fetchPackageMetaData syscall: 'connect',
25 silly fetchPackageMetaData address: '151.101.88.162',
25 silly fetchPackageMetaData port: 443 }
26 silly rollbackFailedOptional Starting
27 silly rollbackFailedOptional Finishing
28 silly runTopLevelLifecycles Finishing
29 silly install printInstalled
30 verbose stack Error: connect ETIMEDOUT 151.101.88.162:443
30 verbose stack at Object.exports._errnoException (util.js:1026:11)
30 verbose stack at exports._exceptionWithHostPort (util.js:1049:20)
30 verbose stack at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
31 verbose cwd C:\Program Files\nodejs
32 error Windows_NT 6.1.7601
33 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "socket.io"
34 error node v6.9.1
35 error npm v3.10.8
36 error code ETIMEDOUT
37 error errno ETIMEDOUT
38 error syscall connect
39 error network connect ETIMEDOUT 151.101.88.162:443
40 error network This is most likely not a problem with npm itself
40 error network and is related to network connectivity.
40 error network In most cases you are behind a proxy or have bad network settings.
40 error network
40 error network If you are behind a proxy, please make sure that the
40 error network 'proxy' config is set properly. See: 'npm help config'
41 verbose exit [ 1, true ]

04-15 08:33