Home  >  Article  >  Web Front-end  >  How to install nodejs in windows environment?

How to install nodejs in windows environment?

青灯夜游
青灯夜游forward
2020-09-03 14:36:082445browse

How to install nodejs in windows environment?

[Video tutorial recommendation: node js tutorial]

1. What is nodejs

Node.js is a JavaScript running environment for Chrome V8 engine. Node.js uses an event-driven, non-blocking I/O model.

Node is a development platform that allows JavaScript to run on the server side. It makes JavaScript a scripting language on par with server-side languages ​​such as PHP and Python.

Developed in 2009 by the master Ryan Dahl.

Essentially node.js is not a library, it is a running environment or a js language interpreter

2. Installation under windows

2.1 Download the installation package

Official website for nodejs download, as shown in the figure below, select the 32-bit or 64-bit installation package to download according to the Windows version.

How to install nodejs in windows environment?

2.2 Double-click the installation package to install

You can go directly to next,

How to install nodejs in windows environment?

to determine the installation location selection, I usually install it in the D drive

..., and finally click finish

How to install nodejs in windows environment?

##2.3 Detect nodejs installation

  • After installing the installation package in the previous step, you need to check whether the installation is successful. Open win r and run, enter cmd to enter the command line interface. Enter the

    node -v and npm -v commands respectively to view the node version number and npm version number.

How to install nodejs in windows environment?

  • The directory after installation is as shown below

How to install nodejs in windows environment?

The npm in the directory is automatically installed with the installation program. Its function is to manage the packages that Node.js depends on.
2.4 Configure the path and cache path for npm to install global modules

Generally, when performing global installation with commands such as

npm install..., the module will be installed by default ## under the path C:\Users\username\AppData\Roaming #npm and npm_cache. No modifications are needed at this time, but it is convenient for managing the C drive data. At this time, we configure our customized global module installation path and cache path, and create two new folders in the current nodejs installation directory. They are node_global

and

node_cache` respectively.

How to install nodejs in windows environment?At this time, you need to open win r and run, enter cmd to enter the command line interface, enter the following content to execute

npm config set perfix "D:\Program Files\nodejs\node_global"
npm config set cache  "D:\Program Files\nodejs\node_cache"

2.5 Configure environment variables

    Create new
  • NODE_PATH

    <pre class="brush:js;toolbar:false">NODE_PATH D:\Program Files\nodejs\node_global\node_modules</pre>

  • in
Edit the path
    of the user variable in #User variable
  • , and modify the corresponding npm path value to the custom

    node_globalpath

    D:\Program Files\nodejs\node_global

2.6 Execute the test

win r open and run cmd, executenpm install webpack -g

to install webpack, the following picture will appear and the configuration is completed .

The following content will be displayed accordingly in the customized file

How to install nodejs in windows environment?

How to install nodejs in windows environment?For more programming-related knowledge, please visit:

Programming Teaching

! ! How to install nodejs in windows environment?

The above is the detailed content of How to install nodejs in windows environment?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete