简体   繁体   中英

How to Start PM2 Node JS with Babel and presets

I'm having the following code in my package.json to start the script while developing:

....
    "scripts": {
        "start": "nodemon src/index.js --exec babel-node --presets es2015,stage-2"
      },
....

Now I want to deploy it to production. When I run npm start everything works fine. However, it will shut down when I close the terminal. So how can I use it with PM2 ?

This is what I've tried:

pm2 start src/index.js -x babel-node -p es2015,stage-2

You can actually use npm start if you like:

$ pm2 start npm -- start

That said, for production deployment I would strongly recommend a) using a config file for your pm2 startup stuff (so you can bundle environment variables and such) and b) precompiling your assets as a build step rather than on startup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM