You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS下VS Code集成终端无法运行nodemon问题求助

Fixing Nodemon Not Working in VS Code Integrated Terminal (macOS)

Hey there, I’ve dealt with this exact frustration before on macOS—let’s get nodemon working in your VS Code terminal right away. The root issue almost always boils down to VS Code not loading the same PATH environment variables as your system terminal, so it can’t find the globally installed nodemon executable.

Here’s how to fix it step by step:

1. Find your global npm bin path first

Open your regular system terminal (the one where nodemon works) and run this command to get the folder where npm installs global binaries:

npm get prefix

You’ll get output like /usr/local or ~/npm-global. Append /bin to this path—so it becomes something like /usr/local/bin or ~/npm-global/bin. This is where nodemon is installed.

2. Check which shell VS Code is using

In VS Code, press Cmd + Shift + P to open the command palette, then search for Select Default Shell. Note whether it’s set to zsh (macOS’s default now) or bash.

3. Update your shell’s config file

VS Code’s integrated terminal might not be loading your shell’s full configuration. Let’s add the npm bin path to your shell’s startup file:

  • If you’re using zsh: Open ~/.zshrc in VS Code (you can use Cmd + O and type ~/.zshrc to open it). Add this line at the bottom:
    export PATH="$(npm get prefix)/bin:$PATH"
    
  • If you’re using bash: Open ~/.bash_profile or ~/.bashrc (whichever exists on your system) and add the same line above.

Save the file, then either restart your VS Code terminal or run this command in the integrated terminal to load the changes immediately:

# For zsh
source ~/.zshrc

# For bash
source ~/.bash_profile

4. Quick alternative: Set PATH directly in VS Code settings

If you don’t want to mess with shell config files, you can set the PATH directly in VS Code:

  1. Press Cmd + , to open settings.
  2. Search for Terminal > Integrated: Env: Osx and click Edit in settings.json.
  3. Add this line (replace /usr/local/bin with your actual npm bin path from step 1):
    "terminal.integrated.env.osx": {
      "PATH": "$PATH:/usr/local/bin"
    }
    
  4. Save the settings and restart the VS Code terminal.

Verify the fix

Run echo $PATH in both your system terminal and VS Code’s integrated terminal—you should now see your npm bin path listed in VS Code’s output. Then try running nodemon again—it should work!

内容的提问来源于stack exchange,提问作者Thuần Nguyễn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:04:40