How to install a NodeJS project locally without an internet connection?

I have a project that I will have to deploy to Windows client systems, where it will be impossible to connect to the Internet. I currently have a folder in the D: \ NODE folder that contains node.exe and npm.cmd and the node_modules folder. To start node from the command line, I added D: \ NODE to the PATH variable.

I can use most of the modules installed locally inside the node_modules of my project. However, there is one - node-windows - that must be installed globally to work.

The following sentence below I went into node-windows (installed globally) and packaged it ( npm pack ), which created the tarball. Then I copied this file with my project and tried to install it on a test computer around the world as follows: npm install -g node-windows-0.1.5.tgz

I see that it has been installed in the global catalog. However, when I try to run a command that 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 present in the list ...

What do you think? And thanks.

+8
windows npm
source share
2 answers

You can install packages on your system without an Internet connection, packaging them using the built-in functions in npm. This way the node modules will be installed correctly.

  • Create package.json .
  • In package.json, list all the modules you need in bundledDependencies .
  • run npm install to install your node files before packaging.
  • Create an archive with npm pack .
  • Copy tarball to computer without internet connection.
  • Install the modules using npm install <filename> .

Update

As for your comments, it looks like your globally installed node modules were not found.

Try using the npm link command ( docs on the npm link ):

  • cd yourAppFolder
  • npm link node-windows
+12
source share

1 - In a system with an Internet access setup module with this command:

 npm install [module name] 

2 - go to% userprofile% \ AppData \ Roaming \ npm \ node_modules [module name] \ (for example, C: \ Users \ janson \ AppData \ Roaming \ npm \ node_modules \ grunt-cli)
3 - run npm pack
4 - this should result in a [module name] -xyztgz file
5 - run npm i -g [module name]-xyztgz on a standalone system

+1
source share

All Articles