What is Node.js?

Simply put, Node.js is JavaScript running on the server. Node.js is a platform built on top of the Chrome JavaScript runtime. Node.js is an event-driven I/O server-side JavaScript environment based on Google’s V8 engine, which executes JavaScript very fast and performs very well.

The official website of Node.js is nodejs.org/en/

A, download


Official download address: nodejs.org/zh-cn/downl…



Second, the installation


Just keep clicking next

Selecting the Installation Position

Add node.js to the system environment variable

The installation is complete

The end of the

Installation Location Directory



Three, test,


Run the CMD command on Windows: node -v: View the node.js version. NPM -v: Displays the NPM version.



4. Change the path for downloading global dependency packages


NPM root -g: NPM root -g: NPM root -g: NPM root -g: NPM root -g: NPM root -g: NPM root -g: NPM root -g: NPM root -g: NPM root -g: NPM root

$ npm root -g
C:\Users\Bealei\AppData\Roaming\npm\node_modules
Copy the code

However, sometimes we don’t want the global package to be in this directory, we can customize the directory and run the following two commands in the CMD window to change the default directory:

$ npm config set prefix "D:\Code\npm"
Copy the code
$ npm config set cache "D:\Code\npm\node_cache"
Copy the code


Configure the PATH environment


Because we changed the path of the global package, it’s natural that the global package we downloaded will be stored in D:\Code\ NPM \node_modules, and the corresponding CMD directive will be stored in D:\Code\ NPM

I installed a vue-CLI scaffold globally:

$ npm install @vue/cli -g
Copy the code

I use CMD vue create myproject command to create a project.

$ vue create myproject
'vue'It is not an internal or external command, nor a runnable program or batch file.Copy the code

This is because when we execute the command, by default it will look for the command file in the node root directory, in this case, vue.cmd, and then it will look for the dependency folder in the node root directory, in this case, @vue, because we changed the path of the global package. So of course I can’t find it.

So we need to add the global package path we specified to the system environment variable so that we can find it.

Test it again, and it works

$ vue create myproject
?  Your connection to the default npm registry seems to be slow.
   Use https://registry.npm.taobao.org for faster installation? (Y/n)
Copy the code