Reputation: 1703
I have a script in package.json
like this. To run with npm I would just do it with npm start
.
"scripts": {
"start": "cd build && node main"
}
I am currently trying to setup a pm2 config file for this. I created a ecosystem.json
file. Neither of both of the following work with pm2 ecosystem
command. What am I doing it wrong?
Note that it work if i manually type cd build && pm2 start main.js
in command but this is not something i want.
First configuration:
{
"apps": [{
"name": "my-app",
"cwd": "build",
"script": "main.js"
}]
}
Second configuration
{
"apps": [
{
"name": "my-app",
"script": "npm",
"args" : "start"
}
]
}
Upvotes: 2
Views: 7947
Reputation: 4983
In your code, you are giving the path incorrectly.
Use following instructions:
Hit pm2 ecosystem
command, this will create a new file by name ecosystem.config.js
Remove all the code from the file and add the following code.
module.exports = {
apps : [
{
name : 'API',
script : 'build/main.js',
}
]
};
Hit pm2 start ecosystem.config.js
Check the logs using pm2 logs
, your app will be started.
Hope this helps you.
Upvotes: 2