Reputation: 547
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: command 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"
}
}
Upvotes: 2
Views: 13048
Reputation: 437
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/compatible 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
Upvotes: 0
Reputation: 1053
You need to install the package globaly(system wide) npm -g install next
Upvotes: 9