美文网首页
node.js 路由

node.js 路由

作者: 一生悬命Cat | 来源:发表于2019-08-12 14:59 被阅读0次

    安装 nodemon(自动重启) 与 cross-env (兼容不容平台)

    npm install nodemon cross-env --save-dev 
    --registry=https://registry.npm.taobao.org
    

    package.json文件

     
    {
      "name": "lianxi",
      "version": "1.0.0",
      "description": "",
      "main": "bin/www.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "dev":"cross-env NODE_ENV=dev nodemon ./bin/www.js"  新增语句
        如果是线上环境
        "prd":"cross-env NODE_ENV=production pm2 ./bin/www.js" 
      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "cross-env": "^5.2.0",
        "nodemon": "^1.19.1"
      }
    }
    
    

    运行

    npm run dev 
    

    成功

    [nodemon] 1.19.1
    [nodemon] to restart at any time, enter `rs`
    [nodemon] watching: *.*
    [nodemon] starting `node ./bin/www.js`
    [nodemon] clean exit - waiting for changes before restart
    

    相关文章

      网友评论

          本文标题:node.js 路由

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