D
D
Dmitry Tarasov2017-04-11 20:41:54
npm
Dmitry Tarasov, 2017-04-11 20:41:54

How to set environment variable in start npm script with label NODE_ENV=development and run gulp task default?

How to set environment variable in npm start script with label NODE_ENV=development and run gulp task default ?
I do so

"scripts": {
    "start": "cross-env NODE_ENV=development&& gulp"
  },

in gulpfile following code
var gulp = require("gulp");

gulp.task('default', function() {
  console.log(process.env.NODE_ENV);
});

192:xxx fast$ npm start

> [email protected]1.0.0 start /Users/xxx/Sites/xxx
> cross-env NODE_ENV=development&& gulp

[20:40:30] Using gulpfile ~/Sites/xxx/gulpfile.js
[20:40:30] Starting 'default'...
undefined
[20:40:30] Finished 'default' after 820 μs

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2017-04-11
@fast-je

&&in this case it is not necessary, since with it it turns out that you first start cross-env NODE_ENV=development, and then gulp.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question