我有nodejs v16.13.0和npm 8.1.0。
当我在cmd或PowerShell (管理员和普通)中运行命令npm help update时,我得到以下错误
npm help update
npm ERR! Invalid URL: file://C:%5CProgram%20Files%5Cnodejs%5Cnode_modules%5Cnpm%5Cdocs%5Coutput%5Ccommands%5Cnpm-update.html我可以确认该文件存在于该位置,但是由于某些原因,该命令没有正确读取路径。是否有需要更改的文件?
我还没有在网上找到任何相关的解决方案...到目前为止,这里也没有。
发布于 2021-11-04 06:59:12
对于所有npm帮助,我都有同样的问题...命令,例如:
C:\DEV\youtube>npm help npm
npm ERR! Invalid URL: file://C:%5CUsers%5Cmirek%5CAppData%5CRoaming%5Cnpm%5Cnode_modules%5Cnpm%5Cdocs%5Coutput%5Ccommands%5Cnpm.html
npm ERR! A complete log of this run file:///C:/Users/mirek/AppData/Roaming/npm/node_modules/npm/docs/output/commands/npm.htmlcan be found in:
npm ERR! C:\Users\mirek\AppData\Local\npm-cache\_logs\2021-11-04T06_20_51_613Z-debug.log似乎编码的URL有问题,因为文件本身是存在的。如果URL解码为
file:///C:/Users/mirek/AppData/Roaming/npm/node_modules/npm/docs/output/commands/npm.html它可以在浏览器中打开,并且工作正常。此外,请根据登录
C:\Users\mirek\AppData\Local\npm-cache\_logs\2021-11-04T06_20_51_613Z-debug.log问题出在
C:\Users\mirek\AppData\Roaming\npm\node_modules\npm\lib\utils\open-url.js:31:11.它尝试验证文件URL是否正确。但是,编码URL显然存在问题。
因此,我尝试注释该文件中的第7行,它编码了URL:
5. // attempt to open URL in web-browser, print address otherwise:
6: const open = async (npm, url, errMsg) => {
7: //url = encodeURI(url)
8: const browser = npm.config.get('browser')经过修改后,它工作得很好。
https://stackoverflow.com/questions/69833995
复制相似问题