如何修复错误nodejs express cannot find module ./response
How to fix the error nodejs express cannot find module ./response
当我运行命令
$ npm 开始
这显示了
> assignment3@1.0.0 start
> nodemon server.js
[nodemon] 2.0.12
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js app.js`
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module './response'
Require stack:
- /Users/hoshidan/nodejsproject/assignment3/node_modules/express/lib/express.js
- /Users/hoshidan/nodejsproject/assignment3/node_modules/express/index.js
- /Users/hoshidan/nodejsproject/assignment3/app.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at Object.<anonymous> (/Users/hoshidan/nodejsproject/assignment3/node_modules/express/lib/express.js:22:11)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/hoshidan/nodejsproject/assignment3/node_modules/express/lib/express.js',
'/Users/hoshidan/nodejsproject/assignment3/node_modules/express/index.js',
'/Users/hoshidan/nodejsproject/assignment3/app.js'
]
}
[nodemon] app crashed - waiting for file changes before starting...
我试图在 node_modules/express/lib/express.js 中搜索,但发现没有文件。
./response
response.js
不知道从哪里开始,我可以重新安装 node_modules 或者你有一些解决此类错误的见解,希望你能帮助我。
您应该尝试重新安装 express:
rm -rf node_modules && npm i
之所以如此,是因为 Express 似乎确实在这里有响应文件:https://github.com/expressjs/express/blob/master/lib/response.js。
P.S.: 制作一个post因为我不能发表评论。
重新安装 express 最终会解决问题。
当我运行命令
$ npm 开始
这显示了
> assignment3@1.0.0 start
> nodemon server.js
[nodemon] 2.0.12
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js app.js`
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module './response'
Require stack:
- /Users/hoshidan/nodejsproject/assignment3/node_modules/express/lib/express.js
- /Users/hoshidan/nodejsproject/assignment3/node_modules/express/index.js
- /Users/hoshidan/nodejsproject/assignment3/app.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at Object.<anonymous> (/Users/hoshidan/nodejsproject/assignment3/node_modules/express/lib/express.js:22:11)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/hoshidan/nodejsproject/assignment3/node_modules/express/lib/express.js',
'/Users/hoshidan/nodejsproject/assignment3/node_modules/express/index.js',
'/Users/hoshidan/nodejsproject/assignment3/app.js'
]
}
[nodemon] app crashed - waiting for file changes before starting...
我试图在 node_modules/express/lib/express.js 中搜索,但发现没有文件。
./response response.js
不知道从哪里开始,我可以重新安装 node_modules 或者你有一些解决此类错误的见解,希望你能帮助我。
您应该尝试重新安装 express:
rm -rf node_modules && npm i
之所以如此,是因为 Express 似乎确实在这里有响应文件:https://github.com/expressjs/express/blob/master/lib/response.js。
P.S.: 制作一个post因为我不能发表评论。
重新安装 express 最终会解决问题。