Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start nodejs app that use cross-env with pm2

I'm trying to start my nodejs app, the default cmd is the following :

pm2 start app.js

I can't do that because I use cross-env and the script as below:

"start": cross-env DOTENV_FILE=.env node build/app.js

So npm run start will launch the script above.

How can I serve my app using pm2 and the script above ?

like image 200
An-droid Avatar asked Oct 04 '17 09:10

An-droid


People also ask

Can pm2 run NPM script?

Yes we can, now pm2 support npm start, --name to species app name.

What is the use of pm2 in node JS?

PM2 is a production process manager for Node. js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.


1 Answers

You can use:

pm2 start npm -- start

or

pm2 start npm --name CrossApp -- run start

Hope this helps

like image 159
Siddharth Srivastva Avatar answered Sep 23 '22 17:09

Siddharth Srivastva