VSCode tasks error: /bin/bash: npm: command not found

半腔热情 提交于 2020-12-05 12:12:32

问题


I've been using node and npm forever. Right now, however, when do command shift p, Tasks: Run task, npm build, I get this error message:

Executing task: npm install <

/bin/bash: npm: command not found The terminal process terminated with exit code: 127

Terminal will be reused by tasks, press any key to close it.

In the terminal, node and npm work fine. I even tried running /bin/bash; node -v and that works fine.


回答1:


Since this is the first result on Google, I want to share my solution despite this being a year old. The problem is that VS Code isn't initializing the NPM command, and many others when using VS Code Tasks. The solution to this is to force VS Code to do so.

This is a very simple thing to do. Simply open up settings.json and add this:

{
  "terminal.integrated.shellArgs.linux": [
    "-i"
  ]
}

I know that this thread is a year-old, but it's the first result I found on Google when going on my search, and while AskYous's solution worked for him, it didn't for me.




回答2:


I found the solution. I had to tell nvm the default node version because I uninstalled a version before I had this error. See here: https://stackoverflow.com/a/34777308/1404347



来源:https://stackoverflow.com/questions/55817159/vscode-tasks-error-bin-bash-npm-command-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!