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 th…


This content originally appeared on DEV Community and was authored by Surjoyday Talukdar

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.


This content originally appeared on DEV Community and was authored by Surjoyday Talukdar


Print Share Comment Cite Upload Translate Updates
APA

Surjoyday Talukdar | Sciencx (2025-03-13T21:09:55+00:00) Fix ‘sh: next: command not found’ in Next.js – Quick & Easy Solution!. Retrieved from https://www.scien.cx/2025/03/13/fix-sh-next-command-not-found-in-next-js-quick-easy-solution/

MLA
" » Fix ‘sh: next: command not found’ in Next.js – Quick & Easy Solution!." Surjoyday Talukdar | Sciencx - Thursday March 13, 2025, https://www.scien.cx/2025/03/13/fix-sh-next-command-not-found-in-next-js-quick-easy-solution/
HARVARD
Surjoyday Talukdar | Sciencx Thursday March 13, 2025 » Fix ‘sh: next: command not found’ in Next.js – Quick & Easy Solution!., viewed ,<https://www.scien.cx/2025/03/13/fix-sh-next-command-not-found-in-next-js-quick-easy-solution/>
VANCOUVER
Surjoyday Talukdar | Sciencx - » Fix ‘sh: next: command not found’ in Next.js – Quick & Easy Solution!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/03/13/fix-sh-next-command-not-found-in-next-js-quick-easy-solution/
CHICAGO
" » Fix ‘sh: next: command not found’ in Next.js – Quick & Easy Solution!." Surjoyday Talukdar | Sciencx - Accessed . https://www.scien.cx/2025/03/13/fix-sh-next-command-not-found-in-next-js-quick-easy-solution/
IEEE
" » Fix ‘sh: next: command not found’ in Next.js – Quick & Easy Solution!." Surjoyday Talukdar | Sciencx [Online]. Available: https://www.scien.cx/2025/03/13/fix-sh-next-command-not-found-in-next-js-quick-easy-solution/. [Accessed: ]
rf:citation
» Fix ‘sh: next: command not found’ in Next.js – Quick & Easy Solution! | Surjoyday Talukdar | Sciencx | https://www.scien.cx/2025/03/13/fix-sh-next-command-not-found-in-next-js-quick-easy-solution/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.