Search code examples
node.jswindowsgulpbrowserify

process.env is an empty object


I am using Gulp / Browserify / Node on Windows, and I want to only include debugging information when in development.

I have a dependant task that is being run before anything else

gulp.task('set-dev-node-env', function() {
    process.env.NODE_ENV = 'development'
}

Yet when I try and access this in my code I am finding process.env is an empty object.

console.log("process.env",process.env)

enter image description here

How can I get this to work?


Solution

  • I found a solution was to use envify

    var envify = require('envify/custom')
    

    and add it as a transform on my browserify() call

    .transform(envify({
                    NODE_ENV: 'development'
                }))