Get pm2, node, npm inject arguments
Using npm:
npm install pm2-node-argv
or using yarn:
yarn add pm2-node-argv
Inject arguments:
pm2 start xxx.js -- --port=5005 --name=lucas
Get arguments:
const { getArgv } = require('pm2-node-argv')
const obj = getArgv();
console.log('obj', obj)
// {
// "port": 5005,
// "name": lucas
// }
Inject arguments:
node xxx.js -- --port=5005 --name=lucas
Get arguments:
const { getArgv } = require('pm2-node-argv')
const obj = getArgv();
console.log('obj', obj)
// {
// "port": 5005,
// "name": lucas
// }
Inject arguments:
pm2 start xxx.js -- --port=5005 --name=lucas
Get arguments:
const { getArgv } = require('pm2-node-argv')
const obj = getArgv();
console.log('obj', obj)
// {
// "port": 5005,
// "name": lucas
// }
npm start xxx -- --port=5005 --name=lucas