#Nestjs monorepo

14 messages · Page 1 of 1 (latest)

normal fable
#

I think that nestjs monorepo is wierd. Because per project have per package.json file. But nestjs monorepo isn't. is nestjs monorepo ready to use in production level?

mystic geyser
#

NestJS and Nx share the philosophy of single package versions. That means that if you use the same package in multiple parts of your application, they should share the package version.

I will say that Nest's monorepo mode is underpowered compared to a dedicated monorepo tool like Nx or turbo, in that you really do only get one package.json and that's it. With Nx you can generate a package.json on application build so that it only contains the packages necessary, which is nice.

lapis bolt
#

I am exploring nestjs monorepo

for standard mode
npm run buid command generates the correct build which I can deploy to aws via serverless - works perfectly fine

however for monorepo mode:
npm run build / npm run build [appname] creating only one file in dist folder i.e. main.js which I believe incomplete build or broken build, upon deployment it throws error

mystic geyser
#

Nope, this is correct.. Monorepo mode uses webpack which bundles the files to a single output

lapis bolt
#

Oh ok, thanks for the info @mystic geyser

Actually I was trying to run it via serverless offline / by deploying it to aws .. it is failing

my serverless.yml looks like

service: serverless-example

plugins:
  - serverless-offline

provider:
  name: aws
  runtime: nodejs16.x

functions:
  main:
    handler: dist/apps/z001/main.handler
    events:
      - http:
          method: ANY
          path: /
      - http:
          method: ANY
          path: '{proxy+}'


#

error:

✖ Unhandled exception in handler 'main'.
✖ /Users/pratiktayade/Documents/work/learn/z001/dist/apps/z001/main.handler is undefined or not exported
mystic geyser
#

You should probably change the serverless config to just point to main as there is not a main.handler file

lapis bolt
#

Oh let me try it out

#

Tried to point it to just main but it came back saying

Unhandled exception in handler 'main'.
✖ Bad handler
mystic geyser
#

Okay, say normally, what is main.handler, cause I don't see the in your original file list

lapis bolt
mystic geyser
#

Hmm, this might not be something I'm aware of how to fix, mainly because I don't use serverless

lapis bolt
#

no worries @mystic geyser
however your input helped me move into the right direction
thank you 🙂