In the first sentence of the text, add “I am participating in the Mid-Autumn Festival Creative Submission Contest. For details, see: Mid-Autumn Festival Creative Submission Contest

1. Download from the official website

Download address :(Nodejs.org/en/download…)

2. Install

Install to a desired directory: E:\tool\node\install next Next

  • Start the installation

  • Installation directory, default is C:\Program Files\nodejs\, modifiable. My change to E:\tool\node\install

  • Proceed to Next, then install

Figure: Installed directory files

3. Check:

  • Make sure you open it as an administrator or an error will occur:operation not permitted, mkdir ‘E:\tool\node\install\node_global’

  • Then enternode -v andnpm -vView the Node and NPM versions respectively

No problem!

New versions of Node.js come with NPM, which is installed with node.js when installed. NPM is used to manage the packages node.js depends on.

4. Configure the environment

  • Note: This environment configuration is mainly to configure the path of the global module installed by NPM, and the path of the cache cache. NPM Install Express [-g] (optional -g, g indicates the global installation), the installed module will be installed in the [C: Users\ User name \AppData\Roaming\ NPM] path, occupy disk C space. \
  • For example, if I want to put the entire module path and cache path in my node.js installation folder, I will create two folders [node_global] and [node_cache] under my installation folder [E:\tool\node\install].

The diagram below:

Code:
npm config set prefix "E:\tool\node\install\node_cache"\

npm config set prefix "E:\tool\node\install\node_global"
Copy the code

Check whether the setting is successful:

 npm config get prefix
 
 npm config get cache
Copy the code
Why check?

Vue cli is installed in node_cache folder, and vue -v is always indicating that the command does not exist, and the vue execution file is only looking for the vue file in node_global

The following:

  • Set environment variables, “My Computer” – right click – “Properties” – “Advanced System Settings” – “Advanced” – “Environment Variables”

  • Create a system environment variable: NODE_PATH, value:E:\tool\node\install\node_modules

  • To modify the Path in the user environment variable, click Edit to replace the original

5. Final test:

  • After the configuration, install a Module test, we install the most commonly used Express module (based on node.js platform, fast, open, minimalist Web development framework), open CMD window, enter the following command to install the module globally:

NPM install express -g # -g

  • I found it in the directory

Done!!

  • One more word:

Goodbay!!!!!!