Home > Net >  Can't run nestjs build without node_modules folder
Can't run nestjs build without node_modules folder

Time:04-01

I'm developing a Nestjs micro-service and need to run the build in dist folder using below command and it's working fine

node dist/main.js

Problem is, above command not working without the node_modules folder. Why can't we run the the build folder(dist) without node_modules folder?

This is the error I'm getting enter image description here

CodePudding user response:

This is Node code, which uses the node_modules folder to search for modules. It cannot run without it. You could try using something like pkg to package it into an executable. The dist folder just contains code, not modules.

CodePudding user response:

No, you can't. Node.js are depended on package.json for finding modules, which also depend on node_modules that store the module. Maybe you want to compile it as one ? Try this https://github.com/vercel/ncc. I never use it for Nest.js before, but you can try it.

  • Related