试图运行nodejs应用程序。如果我运行node server.js,我得到模块未找到错误。所有文件路径都是正确的,但我得到模块未找到错误。如何解决这个问题?
我已将以下错误与文件夹结构共享:
文件夹结构:
test = Main folder
node_modules
src
-controllers =folder
-dataaccess =folder
-routes =folder
-service =folder
-server.js
.angulardoc.json
package.json
package-lock.json
tsconfig.json
tslint.json
错误:
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module './dataaccess/middlewares/base/MiddlewaresBase'
Require stack:
- C:\xampp\htdocs\test\src\server.js
←[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966
:17)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:859:27)←[39m
←[90m at Module.require (internal/modules/cjs/loader.js:1028:19)←[39m
←[90m at require (internal/modules/cjs/helpers.js:72:18)←[39m
at Object.<anonymous> (C:\xampp\htdocs\test\src\server.js
:4:19)
←[90m at Module._compile (internal/modules/cjs/loader.js:1139:30)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:1
0)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:988:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:896:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_ma
in.js:71:12)←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: [ ←[32m'C:\\xampp\\htdocs\\test\\serve
r.js'←[39m ]
}