The premise
1. You are advised to have a computer or VM of the same system version as the Intranet computer.
2. The versions of nodes must be the same
The specific process
Essentially, it configures the relevant environment on the machine that can connect to the Internet and then copies it to the internal machine
-
The following uses 14.16.0 as an example: nodejs.org/zh-cn/
-
Global install vue-CLI, webpack, if you have already installed an older version of vue-CLI (1.x or 2.x) globally, you need to uninstall it first by NPM uninstall vue-cli -g
npm install -g @vue/cli
npm install -g webpack
npm install -g webpack-cli
Copy the code
-
Check the cache directory NPM config get cache, C: / User/Username/AppData/Roaming/NPM – cache is NPM cache files here, this directory will be under NPM and NPM – cache copy to the target machine to replace the same directory
-
Intranet command to install offline dependency packages
Run the NPM root -g command to view the current NPM global installation directory. Then copy the npm-cache directory to the NPM directory
npm install --cache ./npm-cache --optional --cache-min 99999999999 --shrinkwrap false @vue/cli npm install --cache ./npm-cache --optional --cache-min 99999999999 --shrinkwrap false webpack npm install --cache ./npm-cache --optional --cache-min 9999999999999 --shrinkwrap false webpack-cli install @vue/cli offline in npm-cache. Without this plugin the command above specifies that only modules over 999999 minutes will be downloaded from Registry. In effect, all modules are specified to be installed from the cache, which greatly speeds up the download. NPM install --cache./npm-cache --optional --cache-min 99999999999 --shrinkwrap FalseCopy the code
-
Start the project on a networked machine and copy the node_modules folder to the Intranet machine, replacing the node_modules folder in the project
-
Run NPM install dependencies to run the project after installation. If there are dependencies that are not associated, you can rebuild the project dependencies first
-
If vue-cli-service is not an internal or external command, there may be a problem with the node_modules dependency package. The MAC dependency package node_modules does not run on Windows. Have the same system installed dependency package, rerun
-
The node_modules dependency package cannot be installed using CNPM. The dependency package installed using CNPM has a shortcut directory and cannot be copied or compressed to a USB flash drive. You are advised to install the dependency package using NPM
-
Node_modules /. Bin /vue-cli-service: Permission denied Run the chmod 777 project folder /node_modules/. Bin /vue-cli-service command to run the command
Install node-sass in the Intranet environment
- View the current system version
node -p "[process.platform,process.arch,process.versions.modules].join('-')"
Copy the code
- Go to GitHub website of Node-sass to download the corresponding version and save it in a directory, as shown in this example
win32-x64-83_binding.node
It is recommended that you install some projects of Node-sass 4.00^ version 5.0sass-loader
An error occurs.
-
Set path path set SASS_BINARY_PATH=D:/nodejs/.nodes/win32-x64-67_binding.node (modified according to your address and file name) or configure path to use SASS_BINARY_PATH as the system variable
-
Echo %SASS_BINARY_PATH% Checks whether it takes effect
-
NPM install node-sass Install node-sass dependencies can also be installed by NPM install –sass-binary-path= download address
-
Go to node_modules\node-sass to see if there is a vendor folder. If not, create a vendor\win32-x64-83 folder (the folder name is the downloaded version).
- To download the
win32-x64-83_binding.node
Copy it in and rename it to:binding.node
You can!
This is how you install a Node module.
On Linux or Mac, the default directory is the. NPM directory. On Windows, the default directory is %AppData%/npm-cachenpm config get cache
To view the
- Issue the NPM install command
- NPM queries Registry for the url of the module zip package
- Download the compressed package and store it in the nPm-cache directory
- Unzip the package to the node_modules directory of the current project
- run
npm install
Node_modules is checked, not npm-cache. That is, if a module has compressed files in nPm-cache but is not installed in node_modules, NPM will still download a new compressed file from the remote repository. - If the -cache-min parameter can be set in the Intranet environment, it is used to install modules from the cache directory.