node.js 类型错误:请求路径包含未转义的字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18006179/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 15:10:46  来源:igfitidea点击:

TypeError: Request path contains unescaped characters

javascriptnode.jsexpresssocket.ionpm

提问by Walter Caraza

I try to install node.js modules using:

我尝试使用以下方法安装 node.js 模块:

npm install express

but I get this error:

但我收到此错误:

npm http GET https://registry.npmjs.org/express
npm ERR! TypeError: Request path contains unescaped characters.
npm ERR!     at Agent.request (_http_agent.js:264:11)
npm ERR!     at TunnelingAgent.exports.request (http.js:52:22)
npm ERR!     at TunnelingAgent.createSocket (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/tunnel-agent/index.js:117:25)
npm ERR!     at TunnelingAgent.createSecureSocket [as createSocket] (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/tunnel-agent/index.js:184:41)
npm ERR!     at TunnelingAgent.addRequest (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/tunnel-agent/index.js:80:8)
npm ERR!     at new ClientRequest (_http_client.js:112:16)
npm ERR!     at Agent.request (_http_agent.js:279:10)
npm ERR!     at Object.exports.request (https.js:130:22)
npm ERR!     at Request.start (/usr/local/lib/node_modules/npm/node_modules/request/index.js:594:30)
npm ERR!     at Request.end (/usr/local/lib/node_modules/npm/node_modules/request/index.js:1186:28)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 3.6.11-7.fc16.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "express"
npm ERR! cwd /usr/local/src/node
npm ERR! node -v v0.11.5-pre
npm ERR! npm -v 1.3.5
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /usr/local/src/node/npm-debug.log
npm ERR! not ok code 0

May be happening I use a proxy I set it up this way to allow downloads from ips outside my network

可能会发生我使用代理我以这种方式设置它以允许从我网络外的 ip 下载

export https_proxy='http://172.21.0.12:3128'

I hope you can help me

我希望你可以帮助我

回答by smokycat

Set proxy from commandline.

从命令行设置代理。

npm config set proxy http://proxydomain:port/

If error occur yet, additional try next.

如果还发生错误,请继续尝试下一步。

npm config set registry http://registry.npmjs.org/

These work for me. (ref http://sushichop.blogspot.jp/2013/01/npm-install.html)

这些对我有用。(参考http://sushichop.blogspot.jp/2013/01/npm-install.html

回答by bo.

Though late enough, I've bumped into this too after updating nodejs (to 4.1.1) and npm (to something like 1.4.x) on Linux.

虽然已经很晚了,但在 Linux 上更新 nodejs(到 4.1.1)和 npm(到 1.4.x 之类的东西)后,我也遇到了这个问题。

I've tried the suggested solution, but changing the registry entry did not help in all cases. Lastly, having decided to reinstall npm, I found this update source [on npm github][1]

我已经尝试了建议的解决方案,但更改注册表项在所有情况下都没有帮助。最后,决定重新安装 npm,我找到了这个更新源 [on npm github][1]

curl -L https://www.npmjs.org/install.sh | sh

which updated my npm to 3.3.8 and all related package installation troubles have been blown away.

它将我的 npm 更新到 3.3.8,所有相关的包安装问题都被吹走了。