Auto reloading a Sails.js app on code changes?

后端 未结 8 736
花落未央
花落未央 2020-11-30 18:38

Currently is seems that for any code change in a sails.js app you have to manually stop the sails server and run sails lift again before you can see the changes

相关标签:
8条回答
  • 2020-11-30 19:01

    install nodemon globally or locally.

    npm install nodemon --save
    npm install nodemon -g
    

    install sails locally in you project as follows

    npm install sails --save
    

    then change package.json

    from

    "scripts": {
      "debug": "node debug app.js",
      "start": "node app.js"
    },
    

    to

    "scripts": {
       "debug": "node debug app.js",
       "start": "node app.js",
       "dev": "export NODE_ENV=development && nodemon --ignore 'tmp/*' app.js && exit 0"
    },
    

    then

    npm run dev
    
    0 讨论(0)
  • 2020-11-30 19:03

    If you're using Sails 0.11, you can install this hook to automatically reload when you change models or controllers (views do not require reloading):

    npm install sails-hook-autoreload
    

    https://www.npmjs.com/package/sails-hook-autoreload

    0 讨论(0)
提交回复
热议问题