I'm trying Next for the first time (with npx create-next-app
), but I'm not getting the scripts to work. npm run dev
works fine, but next dev
outputs zsh: mand not found: next
. Why is this?
I'm on macOS 12.5, M1. Node version 16.13.1.
It works when I use the debug tool in VS Code.
package.json
:
{
"name": "blog-next",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "12.2.5",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"eslint": "8.22.0",
"eslint-config-next": "12.2.5"
}
}
I'm trying Next for the first time (with npx create-next-app
), but I'm not getting the scripts to work. npm run dev
works fine, but next dev
outputs zsh: mand not found: next
. Why is this?
I'm on macOS 12.5, M1. Node version 16.13.1.
It works when I use the debug tool in VS Code.
package.json
:
{
"name": "blog-next",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "12.2.5",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"eslint": "8.22.0",
"eslint-config-next": "12.2.5"
}
}
Share
asked Aug 17, 2022 at 9:05
Magnus KolstadMagnus Kolstad
5472 gold badges6 silver badges21 bronze badges
2
- Do you need to install the Next cli? nextjs/docs/api-reference/cli – MikeeeG Commented Aug 17, 2022 at 9:08
-
4
Directly typing
next dev
into a mand prompt means the OS has to recognize thenext
mand. This will only work if next itself is installed properly, independent of whatever project you have. Till then,npx next dev
should work – user5734311 Commented Aug 17, 2022 at 9:12
2 Answers
Reset to default 9You need to install the package globaly(system wide) npm -g install next
In my case, this was caused by running over an outdated Node version (v.14x).
After upgrading Node everything worked as expected (Dec 2023: v.20x).
Make sense in fact that Nextjs releases requires/patible with a range of NodeJs versions.
Please, update your NodeJs version.
# nvm users (node version manager)
nvm use 20
# node users
npm install -g node
npm install -g npm