84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
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)
console.log(process.env.NODE_ENV)
But the result shows undefined
undefined
Why?
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
&&
NODE_ENV=dev这里不能有空格"test": "cross-env NODE_ENV=dev&& node test.js"
NODE_ENV=dev
"test": "cross-env NODE_ENV=dev&& node test.js"
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_ENVNODE_ENV=dev
这里不能有空格"test": "cross-env NODE_ENV=dev&& node test.js"