Offline Installation
Make sure to read the Usage as an npm Dependency page first.
On a Machine with Intermittent Internet Access
For such use case, 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. Indeed 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 such 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 use the same Yarn offline mirror feature to rebuild the project
- iterating through all tgz files of that folder, add them to the npm cache and run npm install to rebuild the project
- if you have a local npm registry, iterating through all tgz files of that folder, add them to the registry and run npm install to rebuild the project