Home > Web Front-end > JS Tutorial > body text

Introduction to node.js installation and configuration environment and methods of deploying projects (under Windows system)

青灯夜游
Release: 2020-08-31 10:05:37
forward
2845 people have browsed it

Introduction to node.js installation and configuration environment and methods of deploying projects (under Windows system)

1. Operation steps

①Download node.js

②Install and configure environment variables

③ Deployment project startup access

[Video tutorial recommendation: nodejs tutorial]

2. Detailed steps

1. Select the corresponding system to download :https://nodejs.org/en/download/




##2. Double-click to install







##3,
cmd installed

node -v 显示Node.js的版本说明已经安装成功
npm -v 自带的npm已经安装成功
Copy after login

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"
Copy after login


接下来设置环境变量,关闭cmd窗口,“我的电脑”-右键-“属性”-“高级系统设置”-“高级”-“环境变量”




5、测试

配置完后,安装个module测试下,我们就安装最常用的express模块,打开cmd窗口,

输入如下命令进行模块的全局安装:

npm install express -g     # -g是全局安装的意思
Copy after login


安装完可以看到express版本



6、安装cnpm 下载国内资源

npm install -g cnpm --registry=https://registry.npm.taobao.org
Copy after login

输入cnpm -v输入是否正常

cnpm -v
Copy after login


如果有错

添加系统变量path的内容

  因为cnpm会被安装到D:\Program Files\nodejs\node_global下,而系统变量path并未包含该路径。在系统变量path下添加该路径即可正常使用cnpm。

7、部署项目

cnpm install
Copy after login


8、启动项目

npm run dev
Copy after login


启动成功


访问项目


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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!