alarner / perk

A well documented set of tools for building node web applications.
http://perkframework.com
MIT License
181 stars 31 forks source link

npm run dev should run with NODE_ENV=development #34

Closed alarner closed 8 years ago

alarner commented 8 years ago

Right now when you run npm run dev it runs without any specified environment. Instead, the NODE_ENV environment variable should be set to 'development'.

tphdev commented 8 years ago

@alarner did you already fix this? it looks like you're already setting the environment in /build/server.js on line 13:

    env: Object.assign({}, process.env, { NODE_ENV: 'development', port: 3000 }),
tphdev commented 8 years ago

however, the start script in package.json doesn't have the NODE_ENV specified for production, fwiw

alarner commented 8 years ago

@t3patterson you're right. The problem that we're running into is that by the time the /build/server.js code runs, the configuration file has already been loaded, so it's looking at the NODE_ENV environment variable before it ever gets there. The reason I can tell something is funky is because if Perk is running in development mode it's supposed to use webpack by default but it's currently incorrectly using browserify.

I think the way to fix this would be to update package.json to set NODE_ENV=development in the dev script command immediately before we run the build script.

As for setting NODE_ENV=production for the start script, I think that's a good thing to do as well.