Fix 'sh: next: command not found' in Next.js – Quick & Easy Solution!

I recommend following the steps below, as suggested by timneutkens in the Next.js GitHub issue #8945. Installing Next.js globally can cause multiple issues when deploying to production. Steps to Fix: In your terminal type: nano ~/.zshrc Scroll to the very end of the .zshrc file and add the following lines to include the locally installed node_modules/.bin directory in your PATH: export PATH="./node_modules/.bin:$PATH" Save and exit the file: Press CTRL + X to exit. Press Y to confirm saving. Press Enter to save the changes. Apply the changes by running: source ~/.zshrc This ensures that your locally installed dependencies are prioritized without requiring a global installation of Next.js.

Mar 13, 2025 - 22:45
 0
Fix 'sh: next: command not found' in Next.js – Quick & Easy Solution!

I recommend following the steps below, as suggested by timneutkens in the Next.js GitHub issue #8945. Installing Next.js globally can cause multiple issues when deploying to production.

Steps to Fix:

  1. In your terminal type:
    nano ~/.zshrc

  2. Scroll to the very end of the .zshrc file and add the following lines to include the locally installed node_modules/.bin directory in your PATH:

export PATH="./node_modules/.bin:$PATH"

Save and exit the file:

  • Press CTRL + X to exit.
  • Press Y to confirm saving.
  • Press Enter to save the changes.
  1. Apply the changes by running: source ~/.zshrc

This ensures that your locally installed dependencies are prioritized without requiring a global installation of Next.js.