In my package.json
file I have two scripts, start
and production
, start
script is for local development while production
script is for deployment. Using npm i would just do npm run production
but how do I do this with pm2
Using PM2 to run other npm scripts
I got it, the command is pm2 start npm --name=app-name -- run production
Hello, I tried your solution but I'm always getting the same error : SyntaxError: Unexpected token : 0|backend- | at createScript (vm.js:80:10) 0|backend- | at Object.runInThisContext (vm.js:139:10) –
Metaphor
@BenjaminD. try
pm2 start npm --name=app -- start
–
Pyrrhuloxia It's not working for me. I get an error "Script not found" –
Unmade
@Unmade can you please ask the pm2 forum, because this has always worked for me and frankly i have no other tricks in my sleeves –
Pyrrhuloxia
Install pm2
globally using npm i -g pm2
and then use pm2' command as follow:
pm2 start npm -- production
your command only works for start, in case of production it works with
run production
instead of production
only –
Pyrrhuloxia today i ran my app with : npm run nameScript ,this shot two service in two ports... How can do it with pm2? –
Discombobulate
© 2022 - 2024 — McMap. All rights reserved.
start
script? – Clap