nodejs installation, installation of various modules

Nodejs installation

  • https://nodejs.org/zh-cn/ Installation address
  • node -v Check whether nodejs is installed successfully
  • npm install -g cnpm --registry=https://registry.npm.taobao.org install Taobao mirror globally
  • npm -v Check whether the image is installed successfully

npm install -g cnpm install cnpm

Introduce third-party modules

Create project folder

Initialize the package.json file

Initialization command npm init -y to
install third-party module command analysis
npm install "name" --save => npm i "name" -S

"Name" The name of the third party to be installed –
save will be listed in the dependency file (package.json) for the next download

    {
    
    
        "name": "lol", // 包的名称 不能使用中文
        "version": "1.0.0", // 包的版本号
        "description": "'project'", // 对项目的描述
        "main": "index.js", // 项目的入口文件 配置了入口文件后在模块中引入该包的时候回直接加载该js文件
        "scripts": {
    
    
            "test": "echo \"Error: no test specified\" && exit 1"
        },
        "author": "wang", // 包作者
        "license": "ISC", // 证书 会自动生成
        "dependencies": {
    
     // 依赖清单 npm install 会按照该清单安装所需要的依赖
            "mime": "^2.4.6"
        }
    }

Introduce ejs template

  • Installation command: npm i ejs -S

Refer to https://ejs.bootcss.com/

Introduce mime template

  • Installation command: npm i mime -S

Reference https://blog.csdn.net/h13783313210/article/details/79250685

Introduce express template

  • Installation command: npm i express -S

Refer to https://www.expressjs.com.cn/

Introduce mysql template

  • Installation command: npm i mysql -S

Reference https://www.jianshu.com/p/d2d0d109c18d

Introduce body-parser template

  • Installation command: npm i body-parser -S

Reference https://www.jianshu.com/p/0f02f68ac98c

Install yaen

cnpm install -g yarn

Check whether the installation is successful yarn --version

Express application generator

npm install -g express-generator (install)

express --view=pug myapp (generated)

set DEBUG=myapp:* & npm start (start)

Guess you like

Origin blog.csdn.net/yaoguaia/article/details/107695945