npm ERR! code ENOENT
TL;DRThis npm error means the tool cannot find a file or folder it expects, such as package.json or a dependency path, so the command stops.
Most likely cause: The current folder has no package.json or the file was deleted or moved
Try first: Check what files exist in the current folder (ls -la)
Likely causes
- The current folder has no package.json or the file was deleted or movedmost likely
- A script or config points to a non-existent file or directory pathpossible
- npm is running from the wrong working directoryless likely
How to fix it
Safest first: SafeChanges settingsDangerous
Check what files exist in the current folderSafe
Open a terminal in the project folder and list the files to see if package.json is present.
ls -laNavigate to the correct project folderSafe
Use the cd command to move into the folder that contains your package.json before running npm commands.
cd /path/to/your/projectCreate a missing package.jsonChanges settings
If the file is absent, initialize a new one with npm init. This will not overwrite existing files if you answer the prompts carefully.
npm init
If that didn't fix it
Run the npm command again after adding --verbose to see the exact missing path mentioned in the full error output
When to see a technician
Contact the project maintainer or a Node.js developer if the error occurs inside a shared repository or after a fresh clone.
Related errors
codenpm ERR! code ENOENT: no such file or directory, open 'package.json'codenpm ERR! code ERESOLVEcodenpm ERR! code ERESOLVE unable to resolve dependency treecodenpm ERR! code EACCES: permission denied, mkdir '/usr/local/lib/node_modules'codegyp ERR! find Python | gyp ERR! stack Error: Could not find any Python installation to usecodeERR_CONNECTION_RESET: Connection was reset