我正在尝试从 VS Code 中的 WSL 终端运行 Express 服务器。
但是,每当我运行命令时npm run dev
我收到以下错误:
'\\wsl$\Ubuntu\home\simao\legalize-backend'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
我认为这与从 Windows 到 WSL 目录中的文件夹的路径有关。
哪一种是正确的路径格式,或者我应该做什么才能使这一格式有效?
搜索我发现你可以
You can solve this problem(UNC Paths not supported) by mapping a
normal drive letter to the path that has the UNC path.
但如何将普通驱动器号映射到路径?
我昨天遇到了同样的情况。我想可能是我的 npm 有问题。然后我检查了 npm 路径which npm
,我发现我的npm已经挂载了D:\nodejs\npm
在 Windows 中(确切地说/mnt/d/nodejs/npm
在屏幕中)。
我猜想 WSL 使用 CMD.exe 从 Windows 中启动 npmCMD.EXE was started with the above path as the current directory.
所以也许我可以在 WSL 中安装一个新的 npm 来解决这个问题。节点版本管理器 (nvm) 是安装多个版本 Node.js 的最流行方法。每个版本的nodejs都有自己的npm版本。只需点击下面的链接即可。
安装 nvm、node.js 和 npm
另外,如果你有Permission denied
, use npm uninstall xxx
删除已安装的依赖项,然后再次安装依赖项。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)