How do you usually install the node module offline?
In normal development, we usually install the node module through online installation, but it is also incomplete, and there will be the need for offline installation. For example, the company’s intranet is not networked, so what if you need to install modules?
Today, I will summarize the method of installing the node module offline by installing the global ASAR module offline.
Installation environment: MacOS
Since it is an offline installation, you first need to download the corresponding module through the network. In this paper, through
npm install -D asarTo download the ASAR module and its dependencies. The file structure is as follows:
Offline installation of global ASAR
The principle of method 1 is the same as that of installing node module online
npm intall -g XXXTo install.
First, we create a new node under ASAR folder_ Modules folder, and
test/node_modulesMove all folders except. Bin and ASAR to
test/node_modules/asar/node_modulesUnder the folder, the structure is as follows:
Execute the following command at the terminal (path:
test/node_modules/asarAbsolute path to:
npm install -g /Users/code/test/node_modules/asar
It is then executed in a terminal at any position
asar -V, verify whether the installation is successful, and the results are as follows:
It means that ASAR module has been successfully installed. It’s done!
matters needing attention
On MacOS, the global module installed through this method only generates a soft connection of global instructions. The verification is as follows:
where asar, the results are as follows:
Then go to the path
/usr/local/bin/asarFind ASAR and view its properties:
So, never delete or rename
test/node_modules/asar/File path, otherwise global ASAR will become invalid!
Under windows, after using this method, the entire ASAR folder is completely copied to
AppData/Roaming/npm/node_modulesUnder, deleting the original ASAR folder does not affect the use.
The above is a simple way to install the global node module offline. I hope it can be helpful to you!
Of course, there is more than one way to install node modules offline. What method do you usually use to install node modules offline? Welcome to discuss and exchange in the comment area!
~End of this article, thank you for reading!
Learn interesting knowledge, make interesting friends and shape interesting souls!
You come, with expectations, I have ink to greet you! You return, no matter gain or loss, only with the rhyme!
Pay equal attention to knowledge and skills, cultivate both internal and external skills, grasp both theory and practice, and be hard on both hands!