npm ERR! code ENOENT: no such file or directory, open 'package.json'
TL;DRnpm is trying to open a file called package.json in the current folder but cannot find it. This file lists your project's dependencies and scripts, so most npm commands fail without it.
Most likely cause: You are running the npm command from the wrong folder (not the project root that contains package.json)
Try first: Check which folder you are in (pwd && ls)
Likely causes
- You are running the npm command from the wrong folder (not the project root that contains package.json)most likely
- The package.json file is missing because the project was not initialized or the file was deletedpossible
- A path or filename was typed incorrectly in the commandless likely
How to fix it
Safest first: SafeChanges settingsDangerous
Check which folder you are inSafe
Run this to see the current directory and list files so you can confirm whether package.json exists there.
pwd && lsMove into the correct project folderSafe
Change directory to the folder that actually contains your package.json file.
cd /path/to/your/projectCreate a new package.json if the project has noneChanges settings
If this is a new project, initialize it so npm can create the missing file.
npm init -y
If that didn't fix it
Run 'ls' (or 'dir' on Windows) in the folder and verify the exact spelling and location of package.json before retrying the original npm command.
When to see a technician
See a technician only if you are working inside a shared or production codebase and cannot locate the correct project files.
Quick answers
- What does npm ERR! code ENOENT: no such file or directory, open 'package.json' mean?
- npm is trying to open a file called package.json in the current folder but cannot find it. This file lists your project's dependencies and scripts, so most npm commands fail without it.
- What causes npm ERR! code ENOENT: no such file or directory, open 'package.json'?
- You are running the npm command from the wrong folder (not the project root that contains package.json). (most likely) The package.json file is missing because the project was not initialized or the file was deleted. (possible) A path or filename was typed incorrectly in the command. (less likely)
- How do I fix npm ERR! code ENOENT: no such file or directory, open 'package.json'?
- Try these in order, safest first: 1. Check which folder you are in. 2. Move into the correct project folder. 3. Create a new package.json if the project has none.
- What if that didn't fix it?
- Run 'ls' (or 'dir' on Windows) in the folder and verify the exact spelling and location of package.json before retrying the original npm command.
- When should I see a technician?
- See a technician only if you are working inside a shared or production codebase and cannot locate the correct project files.
Related errors
codenpm ERR! code ERESOLVE unable to resolve dependency treecodenpm ERR! code EACCES: permission denied, mkdir '/usr/local/lib/node_modules'codeModuleNotFoundError: No module named requestscodeUncaught SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSONcode'python' is not recognized as an internal or external command, operable program or batch filecodeERR_CONNECTION_RESET: Connection was reset