美文网首页
Node环境搭建

Node环境搭建

作者: 忘记_3a6a | 来源:发表于2020-03-21 22:37 被阅读0次

    安装NVM: node 多版本管理工具

    安装NRM: 配置安装源,加快安装下载速度

    • 安装:npm install nrm -g

    • 内置源

      PS D:\demo> nrm ls
      
      * npm -------- https://registry.npmjs.org/
      yarn ------- https://registry.yarnpkg.com/
      cnpm ------- http://r.cnpmjs.org/
      taobao ----- https://registry.npm.taobao.org/
      nj --------- https://registry.nodejitsu.com/
      npmMirror -- https://skimdb.npmjs.com/registry/
      edunpm ----- http://registry.enpmjs.org/
      
    • 命令 nrm -h

    • 使用淘宝镜像: nrm use taobao

    安装淘宝npm(cnpm)

    • npm install -g cnpm
    • cnpm -v

    安装nodemon: 避免重复启动服务

    • 安装: npm i -g nodemonnpm install -global nodemon

    • 校验: nodemon -v

    • 启动命令: nodemon src/app.js 配置package.json 后启动命令 npm start

          {
          "name": "demo",
          "version": "1.0.0",
          "description": "",
          "main": "index.js",
          "scripts": {
          "start": "node src/app.js",
          "start-dev": "nodemon src/app.js",
          "test": "echo \"Error: no test specified\" && exit 1"
          },
          "keywords": [],
          "author": "",
          "license": "ISC"
          }
      
    • 配置nodemon监听文件范围

      • nodemon.json
      {
          "watch": ["./src/**/*.*"]   //只监听src下文件
      }
      

    相关文章

      网友评论

          本文标题:Node环境搭建

          本文链接:https://www.haomeiwen.com/subject/oodpyhtx.html