Package nodejs app with global packages
We have a project that needs to be zipped so that we can distribute it to our clients. In the normal node_modules directory, I have no problem. I just put the directory and node.exe together in the project folder and can run our project on any other computer without installing node or running any npm command.
But now I have a phantomjs dependency that needs to be installed as a global package npm install -g phantomjs
.
How can I package such modules into our project? I first thought about copying phantomjs to the local node_modules directory and setting the NODE_PATH path variable to that directory. He doesn't find phantoms.
Development and client platforms are both windows.
source to share
Well, as a rule, you can set global dependencies with a flag --save
both globally and call their type beans ./node_modules/phantomjs/bin/phantomjs /*now executes*/
(as an example).
However, this is not so easy with Phantom as it downloads binaries and / or even compiles. You will have three options:
- ssh to target and only
npm install -g phantomjs
before or define it in manifest, eg.Dockerfile
exactly the same if you are using containers. - Compile it from source as described here .
- If you are using CLI, then just the approach
--save
.
So I hardly advise you to just make a Docker image out of it and send it as a tarball. Unfortunately, you cannot pin the Phantom installation to the platform.
Also a lot of dependencies like karma-runner-phantomjs
looking for the global dependency path to resolve for use.
source to share