【问题标题】:Getting MODULE_NOT_FOUND error in Node.js/Nest.js在 Node.js/Nest.js 中出现 MODULE_NOT_FOUND 错误
【发布时间】:2021-09-17 22:57:28
【问题描述】:

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

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 是微服务的名称。

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

【问题讨论】:

  • 您何时看到此错误?你在跑什么?请添加更多详细信息,以便为您的问题找到正确的解决方案,任何人都很难理解问题所在。
  • @ApoorvaChikara 我已经更新了。我希望现在更清楚了。

标签: node.js microservices nestjs


【解决方案1】:

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

“entryFile”:“服务/帐户/src/main”

【讨论】:

    猜你喜欢
    • 2021-08-14
    • 2020-09-09
    • 2023-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多