Offline Installation
Please ensure that you read the Usage as an npm Dependency page first.
On a Machine with Intermittent Internet Access
For a use case like this, you can leverage the cache of your package manager (npm or Yarn).
On a Machine with no Internet Access
Contrary to what some online resources may suggest, we do not recommend zipping the
node_modules
folder. Some dependencies might use thepreinstall
andpostinstall
npm hooks to hard code contextual information like the current path or the machine operating system. Therefore just copy-pasting thenode_modules
folder would potentially lead to a non working version on the new environment.
In instances like this case, you must provide all the original project dependencies tgz
files in the offline environment.
One method is to use Yarn offline mirror in order to generate a folder containing all the project dependencies tgz
files.
You can then zip that folder and deploy the tgz files on the offline machine by:
- unzipping the folder and using the same Yarn offline mirror feature to rebuild the project
- iterating through all the tgz files of that folder, adding them to the npm cache and running npm install to rebuild the project
- if you have a local npm registry, iterating through all tgz files of that folder, adding them to the registry and running npm install to rebuild the project