Node could not resolve the path or package you required. Run npm install, check the spelling and relative path, and confirm the file exists with the right extension.
- Package import (
require("express")): runnpm install, and check that the package is listed in dependencies and thatnode_modulesis not stale. Deletingnode_modulesand the lock file, then reinstalling, fixes corrupted installs. - Relative import (
require("./utils")): the path must be relative to the importing file, and the case must match on case-sensitive systems like Linux. - ES modules: relative imports need the full extension (
import "./utils.js"), and apackage.jsonwith"type": "module"changes how files are loaded. - Wrong working directory: scripts started from another folder resolve packages from the file's location, not from where you ran the command, so check the entry point's path.
- Build output: if you run compiled code, make sure the build step produced the file and that you start the compiled entry, not the source.
The error message prints a Require stack listing each file in the import chain, so start from the first entry to see which file asked for the missing module.
