首先要说明一点:当使用npm install <module-name>时安装组件时,安装的目录是cmd的目录+node_modules+组件名
例子如下:假如你现在安装express这个组件:
cmd的目录是:D:\Program Files\nodejs\node_modules\npm
如图所示:
则:express这个组件的目录在:D:\Program Files\nodejs\node_modules\npm\node_modules\express
在执行上述命令时喜欢报的错误是:
7 error network request to https://registry.npmjs.org/npm-server failed, reason: connect ETIMEDOUT 151.101.112.162:443 18 error network This is a problem related to network connectivity. 18 error network In most cases you are behind a proxy or have bad network settings. 18 error network 18 error network If you are behind a proxy, please make sure that the 18 error network ‘proxy‘ config is set properly. See: ‘npm help config‘ 19 verbose exit [ 1, true ]
上述的错误其实就是网络代理出现问题:如果你没有使用任何代理
请先输入命令npm config set proxy=null
如果你用了代理写上你自己的代理即可: npm config set proxy=http://135.245.115.111:8000
然后再写上命令npm install express即可