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

已安装nodemon但执行Nodemon [filename.js]提示command not found求助

Fixing "bash: nodemon: command not found" Even When Installed

Hey there, let's troubleshoot this nodemon issue step by step—this is a super common problem with global npm packages, so we'll get it sorted!

Common Solutions to Try

  • Check if your global npm bin path is in your system PATH
    First, find where npm installs global packages by running:

    npm config get prefix
    

    This will return a path like /usr/local or ~/.npm-global. The nodemon executable lives in the bin subfolder of this path. Now check if this bin directory is in your system's PATH:

    echo $PATH
    

    If you don't see the bin path listed, you need to add it to your shell configuration file (like ~/.bashrc, ~/.zshrc, or ~/.profile). For example, if your prefix was ~/.npm-global, add this line to the file:

    export PATH=$PATH:~/.npm-global/bin
    

    Save the file, then restart your terminal or run source ~/.bashrc (replace with your config file name) to apply the changes.

  • Use npx to run nodemon temporarily
    If you need a quick fix without messing with PATH settings, use npx to execute nodemon directly:

    npx nodemon [filename.js]
    

    npx automatically locates the installed nodemon (global or local) and runs it for you.

  • Reinstall nodemon with proper permissions
    Sometimes global installs fail silently due to permission issues. On macOS/Linux, try reinstalling with sudo (be cautious with sudo, but it's safe for npm global packages here):

    sudo npm install -g nodemon
    

    If you prefer not to use sudo, configure npm to install global packages in your user directory instead:

    npm config set prefix '~/.npm-global'
    

    Then follow the first step to add the ~/.npm-global/bin path to your PATH, then run npm install -g nodemon again without sudo.

  • Double-check command case sensitivity
    Bash is case-sensitive! You mentioned running Nodemon [filename.js]—make sure you're using all lowercase:

    nodemon filename.js
    

内容的提问来源于stack exchange,提问作者Ryan Mcguinn

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 08:10:23