Why am I not able to start my application?

Hi there,

for some reason I am not able to start my Next js application. I can not remember to made some changes which could cause this problem and I dont know how to fix it either.

This is the only error message I get in the terminal (after I enter the command ‘npm run dev’):

sh: next: command not found

Can someone help me to figure out whats the issue here?

Have you installed the dependencies?

@nhcarrigan Yes I installed all the dependencies

I just recognized that the node_modules folder is grayed out. In my other projects this is not the case, so it seems something with the node_modules folder is not working.

Screenshot 2022-04-14 at 15.36.30

How can I check whats the issue?

I dont get any error message and I can not check the console.

Please help!!

EDIT: I also recognized that there is no .next folder. What that means? Do I need to install next again?

I tryed to install next app again with npx create-next-app my-app but it did not work. I dont know what to do now…

Maybe it has something to do with the shell. I installed a custom shell and the error message looks like this:

sh: next: command not found

Is there any way to disable the shell?

Can no one help? A hint would already be enough…

node_modules being grayed out is likely just because it is gitignored.

That doesn’t really tell us anything, what isn’t working, how isn’t it working, what happens when you run the command?

You are really the only one that can answer that question. Try in a different terminal.


What happens when you run npx next dev from inside the root Next.js app folder? Is the CLI not working?

I would try removing the node_modules folder and reinstalling the dependencies if not.

@lasjorg Thanks for your answer!

When I run the command npm run dev or npx next -h or npx next dev I always get this message:

sh: next: command not found

No it is not working. I get the same message:

sh: next: command not found

I already did that a few times, but nothing changed.

As I said, I am not able to start the server so I can not see an error message in the console and all I got is:

sh: next: command not found

My apprehension was that I messed up something within the folder structure, but when I try to open older versions (which worked before) I get the same message.

I think I need to start a new Next JS project from scratch and then copy and paste the files into the new project and connect everything again from scretch. This should work, but anyway it would be great to know what is the probleme here.

I am able to start other projects, but this one I am not able to start any version. All versions will give back the same message in the terminal.

What is the best way to deal with such a problem?

What happens if you just run npm -v does it print the version?

Does running next directly from the node_modules folder work?

./node_modules/next/dist/bin/next dev


Try uninstalling the custom shell and reverting back to the default. You can also try switching to Bash just to test it.

Yes it does (version 8.1.0)

No, there is no file like next dev, here is a screenshot:

Is there something missing or do I just dont know how to start via node_modules?

I tested BASH as the shell but got the same issue :frowning:

dev is just the argument/command to next you can run it without the argument (it defaults to dev).

./node_modules/next/dist/bin/next


Does npx create-next-app work if you run it inside the Websites folder?

If so does this project work if you move the root folder to the Websites folder? I’m not very familiar with macs but the file path looks a little odd to me. In general I would avoid anything for folder names other than dashes and underscores. Avoid spaces, dots, and so on.

3 Likes

Finally it works!! It was because of the spaces and the slash I was useing for the folder and project names.

So in general the whole path to the project should be just written in letters (CamelCase) with dashes, underscores and numbers.

Thank you so much, I highly appeachiate your help!! :slight_smile:

1 Like

You solved my bug for me. Thank you!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.