I have a project which I will have to deploy to client Windows systems where it will not be possible to connect to internet. I currently have a folder in D:\NODE which contains node.exe and npm.cmd and a node_modules folder. To be able to run node from command line I have added D:\NODE to PATH variable.
I can have most of the modules installed locally inside node_modules of my project. However there's one - node-windows - which needs to be installed globally to work.
Following suggestion below I went to node-windows (installed globally) and packaged it up (npm pack
), which created a tarball. I have then copied that file with my project and tried to install it on the test machine globally like this: npm install -g node-windows-0.1.5.tgz
I can see that it got installed in the global directory. However when I try to run the command which uses this module it complains that it cannot find it: Error: Cannot find module 'node-windows'
When I list the modules (npm list -g
) it is clearly there in the list...
What do you think? And thank you.
Yes, but simply copying the content of node_modules should be enought, unless you install globally. Another way that may be simpler is to run npm install angular-cli on a connected system, and copy the content of node_modules to the offline computer.
You can install a package locally if you want to depend on the package from your own module, using something like Node. js require . This is npm install 's default behavior.
You can install packages on a system without internet connection by packing them using built-in functionality in npm. This way, the node modules will be installed properly.
bundledDependencies
(docs on npm).npm install
to install your node files before packing. npm pack
.npm install <filename>
.Update
Regarding your comments, it looks like your globally installed node modules isn't found.
Try using the npm link
command (docs on npm link):
cd yourAppFolder
npm link node-windows
1 - In system with internet access install module with this command:
npm install [module name]
2 - go to %userprofile%\AppData\Roaming\npm\node_modules[module name]\ (e.g C:\Users\janson\AppData\Roaming\npm\node_modules\grunt-cli)
3 - run npm pack
4 - this should result in a [module name]-x.y.z.tgz file
5 - run npm i -g [module name]-x.y.z.tgz
in offline system
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With