Installing and Configuring Node.js on Windows

Time:2024-1-24

I. Download the Node.js installation package

Download Address:http://nodejs.cn/download/

This tutorial uses the msi installer as an example

Click on the Windows installation package to download

Installing and Configuring Node.js on Windows

Second, install Node.js

1. Open the installation package

Installing and Configuring Node.js on Windows

Welcome Page: Click Next

2. Terms of Permitted Use

Click to accept the terms and conditionsNext

3. Select the installation path

Select the path where you want to install

This case is saved in the C drive path by default: D:\Soft\nodejs

4. Installation of components

Installing and Configuring Node.js on Windows

These are the components included in Node.js, such as the runtime environment, package manager, etc.

Just leave the defaults as they are and click Next

5. Installation of development tools

Development tools can be installed later during actual development.

Here you can choose not to check the installation tool

6. Install Node.js

Third, check whether the installation is successful

1. Open the terminal

Use Win+R and type cmd

2. Input instructions

node -v
npm -v

Installation is successful when the version number appears

Four, Deployment Node.js

1. Open the terminal with administrator privileges

Move to the Node.js installation directory

cd /d D:\Language\nodejs

2. Create global component folder and cache folder

mkdir node_global
mkdir node_cache

3. Setting the npm global package directory and cache directory

Setting the global catalog
The path to the node_global folder you just created is in double quotes.

npm config set prefix "D:\Language\nodejs\node_global"
npm config set cache "D:\Language\nodejs\node_cache"

4. Setting system environment variables

Replace the npm path in the environment variable Path with the path you just created.Customized node_global global package

In this case D:\Language\nodejs\node_global

After the third step, configure the environment variables as follows:

Installing and Configuring Node.js on Windows

  • “Environment Variables” -> “System Variables”:

    Create a new variable named “NODE_PATH”,

    Variable values:Customized node_global global package path after + \node_modules

    D:\Language\nodejs\node_global\node_modules
    
  • “Environment Variables” -> “User Variables”: edit the user variables in thePath, change the path of the corresponding npm (“C:\Users\Username\AppData\Roaming\npm”) to:”D:\Language\nodejs\node_global“, as follows:

    and new in the Path variable:%NODE_PATH%

V. Testing

Execute the cmd commandnpm install webpack -g respond in singingnpm install webpack-cli -g Install webpack.

The installation was successful and the customized folder is shown below:

Installing and Configuring Node.js on Windows

Installing and Configuring Node.js on Windows

Execute the cmd commandwebpack -v Check the webpack version as shown below:

Installing and Configuring Node.js on Windows

Note that if you get a message that webpack does not exist, remember to open a new cmd to test it.

VI. Solve the problem of slow download speed of npm

rationale

  • mountingNode whennpm The default download address for the package is:https://registry.npmjs.org/
  • Due to extranets, downloads are often slow or not possible, causing us to execute the commandnpm install xxxx Downloading resource packages often fails.

prescription

Configure domestic mirror source address

Usage

  • Temporary use: npm install xxx –registry=mirror source address
  • Change the default download address for npm packages: npm config set registry mirror source address

Attached is the complete.npmrc configuration file

# May require highest privileges for server-side execution
unsafe-perm=true
# Specify installation sources for dependencies
registry=https://registry.npm.taobao.org/
# Specify the source of the node.js installation, some dependencies may require downloading node.js
disturl=https://npm.taobao.org/mirrors/node/
# Dependency files that need to be downloaded within some dependency packages, the following variables will be read and used by the relevant dependency packages
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
chromedriver_cdnurl=https://npm.taobao.org/mirrors/chromedriver/
operadriver_cdnurl=https://npm.taobao.org/mirrors/operadriver/
selenium_cdnurl=https://npm.taobao.org/mirrors/selenium/
node_inspector_cdnurl=https://npm.taobao.org/mirrors/node-inspector/
fsevents_binary_host_mirror=http://npm.taobao.org/mirrors/fsevents/
puppeteer_download_host=https://npm.taobao.org/mirrors/
sentrycli_cdnurl=https://npm.taobao.org/mirrors/sentry-cli/
sharp_binary_host=https://npm.taobao.org/mirrors/sharp/
sharp_libvips_binary_host=https://npm.taobao.org/mirrors/sharp-libvips/
sqlite3_binary_site=https://npm.taobao.org/mirrors/sqlite3/
python_mirror=https://npm.taobao.org/mirrors/python/

PS:

above-mentionednpm.taobao.org Can be fully replaced with the latest Taobao mirror sourcenpmmirror.com
Such as registry=https://registry.npm.taobao.org/ – > registry=https://registry.npmmirror.com/

summarize

The above node.js installation, I have personally tested available, I hope this blog will help you, in the installation and configuration process, if you encounter problems, welcome to leave a message to exchange!

Recommended Today

DML statements in SQL

preamble Previously we have explained DDL statements in SQL statements. Today we will continue with the DML statement of SQL. DML is the Data Manipulation Language.Used to add, delete, and change data operations on the tables in the library.。 1. Add data to the specified field(INSERT) 2. Modify data(UPDATE) 3. Delete data(DELETE) catalogs preamble I. […]