node.js - Could not find Nx modules in this workspace while using Heroku deployment for NestJS app - Stack Overflow

I have an Nx workspace (v. 20.1) with a NestJS app. Locally, everything works fine, nx build, etc. But

I have an Nx workspace (v. 20.1) with a NestJS app. Locally, everything works fine, nx build, etc. But when running CI on Heroku, I get this error:

NX Could not find Nx modules in this workspace.

My package.json:

...
"scripts": {
    "heroku-prebuild": "npm install && npm run build:prod",
    "build:prod": "nx build my-node-app --configuration production",
...
}
...

I have an Nx workspace (v. 20.1) with a NestJS app. Locally, everything works fine, nx build, etc. But when running CI on Heroku, I get this error:

NX Could not find Nx modules in this workspace.

My package.json:

...
"scripts": {
    "heroku-prebuild": "npm install && npm run build:prod",
    "build:prod": "nx build my-node-app --configuration production",
...
}
...
Share Improve this question asked Nov 20, 2024 at 20:33 Sebastian DenisSebastian Denis 1,03112 silver badges21 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

So, after many tries, I've found the issue which was not using "heroku-postbuild" script for nx build. It looks like prebuild doesn't wait for npm install, and nx is unavailable.

Here is the working package.json:

...
"scripts": {
    "heroku-prebuild": "npm install",
    "heroku-postbuild": "nx build my-node-app --configuration production",
    "start": "node dist/apps/my-node-app/main.js",
    "build:prod": "nx build my-node-app --configuration production"
  },
...

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742330047a4423534.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信