/pm2-node-argv

This is pm2, node, npm get Inject arguments.

Primary LanguageJavaScript

pm2-node-argv

Get pm2, node, npm inject arguments

Install

Using npm:

npm install pm2-node-argv

or using yarn:

yarn add pm2-node-argv

How to Use ?

Pm2

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
// }

Node

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
// }

Npm

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