What is Node.js?
Simply put Node.js is running on the server side JavaScript.
Node.js is a JavaScript runtime environment Chrome V8 engine;
Node.js using an event-driven, non-blocking I / O model, it lightweight and efficient;
Node.js ecosystem package npm is the world's largest repository of open source ecosystem.
Installation Tutorial
Native environment: Windows 7 Ultimate 64bit operating system
1. Download the installation package
Node.js official website: https://nodejs.org/en/download/
The download is complete, the installation package is as follows:
2. Install
Double-click to open the installation, the next step to the next step (the author installation path is "D: \ Program Files \ nodejs"):
……
Successful installation, testing whether the installation is successful, run the CMD, are input node -v and npm -v respectively npm view the version number of the node, and, as shown below:
After the installation is complete as shown in FIG system directory (wherein, NPM automatically installed with the installation, the effect is dependent on Node.js management package):
3. Configure npm path and caching global cache module during installation path
For example, when performing because npm install webpack -g command and other global installed, the default with modules installed in C: \ Users \ username \ AppData \ npm and npm_cache under Roaming path management is not convenient and takes up C drive space,
So here the global module configured custom installation directory, create two folders node_global and node_cache, as shown in FIG. Node.js installation directory:
Then execute the following two commands in cmd command:
npm config set prefix "D:\Program Files\nodejs\node_global" npm config set cache "D:\Program Files\nodejs\node_cache"
执行命令,如下图所示:
执行完后,配置环境变量,如下:
- “环境变量” -> “系统变量”:新建一个变量名为 “NODE_PATH”, 值为“D:\Program Files\nodejs\node_modules”,如下图:
- “环境变量” -> “用户变量”:编辑用户变量里的Path,将相应npm的路径(“C:\Users\用户名\AppData\Roaming\npm”)改为:“D:\Program Files\nodejs\node_global”,如下:
配置完成。
4.测试
在cmd命令下执行 npm install webpack -g 安装webpack,如下图所示:
安装成功,自定义文件夹如下所示:
在cmd命令下执行 npm webpack -v 查看webpack版本,如下图所示:
总结
以上node.js的安装,笔者已亲测可用,希望本篇博客对您有所帮助,在安装配置过程中,若遇到问题,欢迎留言交流!