-
-
Notifications
You must be signed in to change notification settings - Fork 22.1k
Description
Hello Express Community,
I've been encountering persistent issues with my Express.js application that I haven't been able to resolve despite numerous troubleshooting attempts. Below are the details of the problems and the steps I've taken so far.
Environment:
Node.js Version: v22.12.0
Express.js Version: latest
Operating System: Windows 11
Issues Encountered:
1: Error When Running node index.js:
node:internal/modules/cjs/loader:1252
throw err;
^
Error: Cannot find module './middleware/query'
Require stack:
- ...\node_modules\express\lib\application.js
- ...\node_modules\express\lib\express.js
- ...\node_modules\express\index.js
- ...\index.js
at Function._resolveFilename (node:internal/modules/cjs/loader:1249:15)
...
code: 'MODULE_NOT_FOUND',
requireStack: [
'...\node_modules\express\lib\application.js',
'...\node_modules\express\lib\express.js',
'...\node_modules\express\index.js',
'...\index.js'
]
}
Node.js v22.12.0
2: Error When Using Nodemon (npm start):
Error: Cannot find module '...\node_modules\nodemon\node_modules\brace-expansion\index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:494:19)
...
code: 'MODULE_NOT_FOUND',
path: '...\\brace-expansion\\package.json',
requestPath: 'brace-expansion'
}
Node.js v22.12.0
Steps Taken to Resolve:
Reinstalled node_modules: Deleted the node_modules folder and ran npm install multiple times.
Reinstalled Node.js: Completely removed Node.js and installed the latest version.
Tried Alternative Package Managers: Switched between npm, Yarn, and pnpm without success.
Tested with Other Frameworks: Created simple boilerplate projects using Fastify and NestJS, which run without issues.
Used Different Boilerplates: Even with a fresh Express boilerplate, the same errors persist.
Additional Information:
The issue persists even with a fresh Express setup.
Other Node.js frameworks like Fastify and NestJS work flawlessly on the same environment.
Suspect it might be related to Express's internal modules or compatibility with the current Node.js version.
.
Request for Assistance:
Has anyone encountered similar issues with Express.js, particularly related to missing internal modules like ./middleware/query or brace-expansion? Any insights or suggestions on how to resolve these module resolution errors would be greatly appreciated.
Thank you in advance for your help!