The installation and construction tutorial of the Node.js environment under the Windows system allows you to get started quickly!

If you want to understand and learn Node.js in depth then the first thing you need to do first is to install Node.js. How to install the Node.js environment is definitely confusing for newbies. 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, Python, Perl, and Ruby. Released in May 2009 and developed by Ryan Dahl, it essentially encapsulates the Chrome V8 engine. Here I will share with you how to build Node.js in the Windows environment system.

first step

First of all, you need to download Node.js (12.13.0 is used as an example here), after downloading, all are installed by default until the completion.

Official download: https://nodejs.org/en/

second step

Test whether the installation is successful

Enter the CMD command in the start menu to open the command window. Enter node -v or npm -v and press Enter. If the corresponding version number is displayed, the installation is successful.

set cache folder

If you do not configure the environment, the default environment will perform operations under C:\Users\username\AppData\Roaming\npm, which will take up part of the space on the C drive, so consider configuring the environment to save space. Of course, if you think it is not necessary, you can ignore this step.

Create a cache cache and a global global folder (you can specify the specific path yourself).

Enter the CMD command in the start menu to open the command window. After entering, press Enter to confirm, and press Enter once for each line.

1

npm config set prefix "D:\nodejs\node_global"

1

npm config set cache "D:\nodejs\node_cache"

third step

Configure the Node.js environment

1. [My Computer] - Right Click - [Properties] - [Advanced System Settings] - [Advanced] - [Environment Variables]

2. Enter the environment variable, create a new [NODE_PATH] under [System Variables], and enter [D:\nodejs\node_modules]

3. Change [Path] under [User Variables] to [D:\nodejs\node_global]

the fourth step

test environment

Install the express module for testing.

Enter the CMD command in the start menu to open the command window.

1

npm install express -g

If you set the local path to find the installation file, then it is successful.

NPM command Error: EINVAL: invalid argument, mkdir Solution:

Manually change the cache and predix of settings NPM.

Manually change the "C:\Users\.npmrc" file, open it in Notepad, the content is as follows:

prefix=C:\Program

Because of this non-existent directory, an error has been reported. Modify the text content to the correct configuration path:

1
2

prefix=D:\nodejs\node_global
cache=D:\nodejs\node_cache

Re-open the command line and run the npm command to be normal

additional decompilation

1. Open the Windows PowerShell command window as an administrator to install asar

1

npm install -g asar

2. Open Windows PowerShell as administrator and enter

1

asar extract app.asar ./

Guess you like

Origin blog.csdn.net/winkexin/article/details/131838164