Error: Cannot find module (node:internal/modules/cjs/loader)
Most likely cause: Dependencies were never installed or the install failed, so node_modules is missing or incomplete
Try first: Read which module is missing
Likely causes
- Dependencies were never installed or the install failed, so node_modules is missing or incompletemost likely
- The command was run from the wrong folder, or the script/file path is misspelledpossible
- The package is used in code but not listed in package.jsonpossible
- Wrong letter case in a file name (works on Windows/macOS, fails on Linux)less likely
How to fix it
Read which module is missingSafe
Look at the first line: Error: Cannot find module 'NAME'. A plain name means a package; a path (starting with ./, / or C:\) means a file.
Check you are in the project folderSafe
Make sure the terminal is in the folder that contains package.json and that the file you run exists there.
ls package.jsonInstall dependenciesChanges settings
Install everything listed in package.json.
npm installAdd the missing packageChanges settings
If the missing name is a package not in package.json, install it (replace NAME with the module name from the error).
npm install NAMEReinstall node_modules cleanlyDangerous
Delete node_modules and reinstall. If package-lock.json exists, npm ci installs exactly the locked versions.
rm -rf node_modules && npm ci⚠ Only node_modules is deleted; commit or back up your project first. Use npm install instead of npm ci if there is no package-lock.json.
If that didn't fix it
Check that the path and file name match exactly, including upper and lower case, and that "main" or the start script in package.json points to a file that exists.
When to see a technician
Consult a developer or support if the error continues after a clean npm install and you cannot identify the missing module name.
Quick answers
- What does Error: Cannot find module (node:internal/modules/cjs/loader) mean?
- This Node.js error means require() or import could not find a module. The node:internal/modules/cjs/loader line is just where Node reports it; read the module name in quotes on the first line. If it is a package name (like 'express'), the package is not installed. If it is a file path (like '/app/index.js'), Node could not find that file, often because you ran the command from the wrong folder.
- What causes Error: Cannot find module (node:internal/modules/cjs/loader)?
- Dependencies were never installed or the install failed, so node_modules is missing or incomplete. (most likely) The command was run from the wrong folder, or the script/file path is misspelled. (possible) The package is used in code but not listed in package.json. (possible) Wrong letter case in a file name (works on Windows/macOS, fails on Linux). (less likely)
- How do I fix Error: Cannot find module (node:internal/modules/cjs/loader)?
- Try these in order, safest first: 1. Read which module is missing. 2. Check you are in the project folder. 3. Install dependencies. 4. Add the missing package. 5. Reinstall node_modules cleanly.
- What if that didn't fix it?
- Check that the path and file name match exactly, including upper and lower case, and that "main" or the start script in package.json points to a file that exists.
- When should I see a technician?
- Consult a developer or support if the error continues after a clean npm install and you cannot identify the missing module name.