node.jsnpmnode-modulesnpm-installnodejs-server

NPM: Can general npm binary dependencies be built statically?


This question is about server-only applications.

Is there any ability to build statically dependencies that are usually building from sources when we install them via npm install? Some params or flags maybe?

I want to get node_modules that are independent from system libraries (except something very basic like glibc) and can be moved to other hosts where there are no custom dependencies.


Solution

  • Short answer: No. If a library require a build process, you can't skip it with a flag or param of npm.

    You can download the library, understand the build process, build the binary for each of your required environments, make some adjustments to the code so it will use the pre built binaries, upload it as a new npm package (in case the original library license allow that), and you are good to go...