gpt4 book ai didi

node.js - npm 安装抛出错误错误 : Invalid protocol

转载 作者:搜寻专家 更新时间:2023-10-31 23:09:43 26 4
gpt4 key购买 nike

你好,我是 Node JS 的新手,我正在尝试按照书中的示例进行操作,当尝试执行 npm install 时,我收到以下错误:

任何帮助将不胜感激

 C:\Developer\NODE_JS>npm install
npm WARN package.json chatrooms@0.0.1 No repository field.
npm WARN package.json chatrooms@0.0.1 No README data
npm http GET http://registry.npmjs.org/socket.io
npm http GET http://registry.npmjs.org/mime
npm http GET http://registry.npmjs.org/socket.io
npm http GET http://registry.npmjs.org/mime
npm http GET http://registry.npmjs.org/socket.io
npm http GET http://registry.npmjs.org/mime
npm ERR! Error: Invalid protocol
npm ERR! at Request.init (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:335:51)
npm ERR! at new Request (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:99:8)
npm ERR! at request (C:\Program Files\nodejs\node_modules\npm\node_modules\request\index.js:55:11)
npm ERR! at RegClient.makeRequest (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:211:13)
npm ERR! at RegClient.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:117:17)
npm ERR! at null._onTimeout (C:\Program Files\nodejs\node_modules\npm\node_modules\retry\lib\retry_operation.js:32:10)
npm ERR! at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/isaacs/npm/issues>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Developer\NODE_JS
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.3.21
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Developer\NODE_JS\npm-debug.log
npm ERR! not ok code 0

我的 Node js配置是

C:\Developer\NODE_JS>npm config list
; cli configs
registry = "http://registry.npmjs.org/"

; userconfig C:\Users\<uname>\.npmrc
https-proxy = "proxy.<comp>.com:8080"
proxy = "proxy.<comp>.com:8080"
registry = "http://registry.npmjs.org/"

; builtin config undefined
prefix = "C:\\Users\\puppalap\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\\node.exe
; cwd = C:\Developer\NODE_JS
; HOME = C:\Users\<uname>
; 'npm config ls -l' to show all defaults.

最佳答案

设置以下两个属性后问题得到解决:

npm config set proxy http://usr:pwd@host:port
npm config set https-proxy http://usr:pwd@host:port

关于node.js - npm 安装抛出错误错误 : Invalid protocol,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21269061/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com