DEV Community

Cover image for How to use open source nodejs project's build or bundle in another nodejs project by importing?
Jatin Anand
Jatin Anand

Posted on

How to use open source nodejs project's build or bundle in another nodejs project by importing?

I have tried to make a package of an open-source nodejs project using the following command.

npm pack
or
npm pack

After I got the tar file, I installed it by

npm install tar_file_path

After I used required api in another Nodejs project, it could not load or import properly. I am not able to launch or update the index.html file of the packaged folder.

Please guide me or help me fix this problem.

Thanks

Top comments (1)

Collapse
 
asmyshlyaev177 profile image
Alex • Edited

I thought need to build it first with npm run build, maybe use npm workspaces (or yarn workspaces), to import files from another project, or some tool for monorepos, like turbopack. Not a pro in this either.

I had a library code, and few examples that import it via npm workspaces. Basically different folders, evey one has it's own package.json, and workspaces defined in a main packages.json
github.com/asmyshlyaev177/state-in...
This way can see changes in real time if change library code.