Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get "sh: next: command not found" when running a cloned nextjs app?

Tags:

next.js

I've cloned a nextjs example repo locally, and tried to run it using npm run dev, but it's not finding "next" as a command?

sh: next: command not found

I googled it, suggestions seemed to be that I should run

npm i -g create-next-app

Which I did, but still get the same error?

How can I resolve this?

like image 257
Brad Parks Avatar asked Sep 12 '25 23:09

Brad Parks


1 Answers

For my particular case, I forgot to run npm install in the repo I'd just cloned :D

Once I did that, running npm run dev worked fine and found next.

But I suspect in general if you're trying to run a cloned repo based on npm, and get a similar response, you may simply have forgotten to install your dependencies, like I did.

Note that this can also happen for an existing project if you have some script that removes the node_modules folder as part of a cleanup process (which I do as well)

like image 142
Brad Parks Avatar answered Sep 16 '25 08:09

Brad Parks