What Causes This Error?
This error occurs when you try to run Nuxt commands but the nuxt package isn’t listed in your package.json dependencies.
The Problem
{
"name": "my-project",
"dependencies": {
"vue": "^3.4.0"
// ❌ Missing nuxt
}
}
The Fix
Install Nuxt
# Using npm
npm install nuxt
# Using pnpm
pnpm add nuxt
# Using yarn
yarn add nuxt
Verify Installation
{
"dependencies": {
"nuxt": "^3.10.0" // ✅ Should appear here
}
}
Common Scenarios
New Project Setup
# Best way to start a new Nuxt project
npx nuxi init my-project
cd my-project
npm install
Cloned Repository
# If you cloned a repo, install dependencies
git clone <repo-url>
cd my-nuxt-app
npm install # This installs nuxt from package.json
Wrong Directory
# Make sure you're in the right directory
ls package.json # Should show your package.json
# Navigate to correct directory
cd /path/to/my-nuxt-app
Checking Package.json
Correct Structure
{
"name": "my-nuxt-app",
"private": true,
"type": "module",
"scripts": {
"dev": "nuxi dev",
"build": "nuxi build",
"preview": "nuxi preview",
"postinstall": "nuxi prepare"
},
"dependencies": {
"nuxt": "^3.10.0"
}
}
If Nuxt Is Missing
# Add it
npm install nuxt
Corrupted Installation
If nuxt is in package.json but still getting errors:
# Clean install
rm -rf node_modules
rm package-lock.json # or pnpm-lock.yaml, yarn.lock
npm install
Global vs Local Installation
# ❌ Global installation might cause issues
npm install -g nuxt
# ✅ Always install locally
npm install nuxt
Version Mismatch
Nuxt 3
{
"dependencies": {
"nuxt": "^3.0.0"
}
}
Nuxt 2 (Legacy)
{
"dependencies": {
"nuxt": "^2.0.0"
}
}
Monorepo Setup
In a monorepo, ensure nuxt is in the correct package:
my-monorepo/
├── packages/
│ └── my-nuxt-app/
│ └── package.json ← nuxt should be here
└── package.json ← Or here if hoisted
// packages/my-nuxt-app/package.json
{
"dependencies": {
"nuxt": "^3.10.0"
}
}
pnpm Workspace
# pnpm-workspace.yaml
packages:
- 'packages/*'
# Install from workspace root
pnpm install
Troubleshooting
Check If nuxt Is Installed
# Should show nuxt version
npm list nuxt
# Or check node_modules
ls node_modules/nuxt
Verify package.json Syntax
# Check for JSON errors
node -e "require('./package.json')"
Check Node Version
# Nuxt 3 requires Node 18+
node --version
Migrating from Nuxt 2
# Remove old nuxt
npm uninstall nuxt nuxt-edge
# Install Nuxt 3
npm install nuxt
Update package.json scripts:
{
"scripts": {
"dev": "nuxi dev", // Changed from "nuxt"
"build": "nuxi build", // Changed from "nuxt build"
"preview": "nuxi preview"
}
}
Quick Checklist
-
nuxtis listed in package.json dependencies -
npm installhas been run - In correct project directory
- node_modules exists and contains nuxt
- No JSON syntax errors in package.json
- Node.js version is 18+