1.安装脚手架命令
npm install -g vue-cli
2.错误
PS D:\myvue> npm install -g vue-cli
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to http://registry.npmjs.org/vue-cli failed, reason: connect ECONNREFUSED 127.0.0.1:80
npm ERR! at ClientRequest.<anonymous> (D:\Download\Node.js\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:400:28)
npm ERR! at Socket.socketErrorListener (_http_client.js:475:9)
npm ERR! at Socket.emit (events.js:400:28)
npm ERR! at emitErrorNT (internal/streams/destroy.js:106:8)
npm ERR! at emitErrorCloseNT (internal/streams/destroy.js:74:3)
npm ERR! at processTicksAndRejections (internal/process/task_queues.js:82:21)
npm ERR! FetchError: request to http://registry.npmjs.org/vue-cli failed, reason: connect ECONNREFUSED 127.0.0.1:80
npm ERR! at ClientRequest.<anonymous> (D:\Download\Node.js\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:400:28)
npm ERR! at Socket.socketErrorListener (_http_client.js:475:9)
npm ERR! at Socket.emit (events.js:400:28)
npm ERR! at emitErrorNT (internal/streams/destroy.js:106:8)
npm ERR! at emitErrorCloseNT (internal/streams/destroy.js:74:3)
npm ERR! errno: 'ECONNREFUSED',
npm ERR! code: 'ECONNREFUSED'
npm ERR! }
npm ERR!
npm ERR! 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2022-07-06T08_36_44_014Z-debug.log
3.解决方法
npm config set proxy false
npm cache verify
# 查看自己的安装源
npm config get registry
# 更换npm源为国内淘宝镜像
npm config set registry http://registry.npm.taobao.org/
# 或者更换为国内npm官方镜像
npm config set registry http://registry.cnpmjs.org/
# 还原npm源
npm config set registry https://registry.npmjs.org/