最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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"
  },
...

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论