Win10的Ubuntu子系统运行npm命令报错的解决方案

转载自:https://github.com/Microsoft/WSL/issues/1512

I was having this issue when running zsh with oh-my-zsh inside the WSL. but changing the PATH helped.

In my ~/.bashrc

I have this script to automatically go to zsh when launching bash:

I installed node for the Ubuntu side too with the command above:

But I was still running into the same error because my which npm pointed to Program Files, while sudo which npm pointed usr/bin/npm. Exporting the correct path was the correct solution, the oh-my-zsh creates a handy configured ~/.zshrc file, which has this on top:

Which I changed to the default Ubuntu one export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games and sourced the file with source ~/.zshrc and everything started working just fine.

0 条评论

昵称

沙发空缺中,还不快抢~