在 Node.js/Nest.js 中出现 MODULE_NOT_FOUND 错误

Getting MODULE_NOT_FOUND error in Node.js/Nest.js

我在尝试 运行 名为 -> 帐户的微服务时遇到了这个问题。

yarn run v1.22.5
$ nest start
internal/modules/cjs/loader.js:905

Error: Cannot find module '/home/node/services/accounts/dist/main'
     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
     at Function.Module._load (internal/modules/cjs/loader.js:746:27)
     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
     at internal/main/run_main_module.js:17:47 {
   code: 'MODULE_NOT_FOUND',
   requireStack: []
 }

 error Command failed with exit code 1.
 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

其中,accounts 是微服务的名称。

我尝试使用 运行ning yarn install 但仍然出现同样的错误。 此外,我尝试删除 dist 文件夹并重新启动微服务,但同样的问题仍然存在。

在我的 accounts 微服务的 nest-cli.json 文件中添加以下条目后问题得到解决:

“条目文件”:“services/accounts/src/main”