Home>Article>Web Front-end> Introduction to node.js installation and configuration environment and methods of deploying projects (under Windows system)
①Download node.js
②Install and configure environment variables
③ Deployment project startup access
[Video tutorial recommendation:nodejs tutorial]
1. Select the corresponding system to download :https://nodejs.org/en/download/
##3,
cmd installed
node -v 显示Node.js的版本说明已经安装成功 npm -v 自带的npm已经安装成功
installed As shown in the figure:
Here is a description: The new version of Node.js has its own npm, which will be installed when Node.js is installed. The function of npm is to carry out the packages that Node.js depends on. Management can also be understood as the things needed to install/uninstall Node.js.
4,Environment variable configuration
Instructions: Here The environment configuration mainly configures the path where the global module installed by npm is located, and the path of the cache. The reason for configuring it is because in the future, it is similar to: npm install express [-g] (the optional parameter -g later, g stands for global installation), the installed module will be installed in the path [C:\Users\username\AppData\Roaming\npm], occupying C drive space.
例如:我希望将全模块所在路径和缓存路径放在我node.js安装的文件夹中,则在我安装的文件夹【D:\Develop\nodejs】下创建两个文件夹【node_global】及【node_cache】如下图:
创建完两个空文件夹之后,打开cmd命令窗口,输入
npm config set prefix "D:\Develop\nodejs\node_global" npm config set cache "D:\Develop\nodejs\node_cache"
接下来设置环境变量,关闭cmd窗口,“我的电脑”-右键-“属性”-“高级系统设置”-“高级”-“环境变量”
5、测试
配置完后,安装个module测试下,我们就安装最常用的express模块,打开cmd窗口,
输入如下命令进行模块的全局安装:
npm install express -g # -g是全局安装的意思
安装完可以看到express版本
6、安装cnpm 下载国内资源
npm install -g cnpm --registry=https://registry.npm.taobao.org
输入cnpm -v输入是否正常
cnpm -v
如果有错
添加系统变量path的内容
因为cnpm会被安装到D:\Program Files\nodejs\node_global下,而系统变量path并未包含该路径。在系统变量path下添加该路径即可正常使用cnpm。
7、部署项目
cnpm install
8、启动项目
npm run dev
启动成功
访问项目
At this point, installing node.js under Windows, configuring environment variables, and deploying the project are over. If you have any questions, leave a comment and we will reply as soon as possible.
For more programming-related knowledge, please visit:Introduction to Programming! !
The above is the detailed content of Introduction to node.js installation and configuration environment and methods of deploying projects (under Windows system). For more information, please follow other related articles on the PHP Chinese website!