Home  >  Q&A  >  body text

javascript - What to do if cross-env doesn't work?

The scripts statements in package.json are as follows

"test": "cross-env NODE_ENV=dev && node test.js"

test.js has only one sentence console.log(process.env.NODE_ENV)

But the result shows undefined

Why?

淡淡烟草味淡淡烟草味2710 days ago1006

reply all(2)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-19 10:19:26

    Ask and answer your own question, the reason is that there cannot be anything in the middle&&&&This will divide the two environments before and after, resulting in the environment of the latter statement not having NODE_ENV

    reply
    0
  • PHPz

    PHPz2017-05-19 10:19:26

    NODE_ENV=dev这里不能有空格
    "test": "cross-env NODE_ENV=dev&& node test.js"

    reply
    0
  • Cancelreply