Reputation: 5034
Is there a way to configure package.json to run a different npm start
script based on context? For example, I would like to run DEBUG=http nodemon app.js
when I am developing. But, I would like to run node app.js
on production.
Upvotes: 0
Views: 114
Reputation: 620
Create a new file (e.g. server.js) and insert your app.js content.
Use this code sample inside of app.js
var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { sys.puts(stdout) }
var isDev = // Check if on dev machine
if(isDev){
exec("DEBUG=http nodemon server.js", puts);
} else {
exec("node server.js", puts);
}
Upvotes: 1