1 回答

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊
creact-react-app創(chuàng)建的項(xiàng)目是無(wú)法手動(dòng)指定NODE_ENV的,NODE_ENV在你選擇執(zhí)行命令時(shí)已經(jīng)確定下來(lái),npm start時(shí),NODE_ENV='development';npm run build 時(shí),NODE_ENV='production',你無(wú)法覆蓋默認(rèn)選項(xiàng),下面是creact-react-app官網(wǎng)的原話:
When you run npm start, it is always equal to 'development', when you run npm test it is always equal to 'test', and when you run npm run build to make a production bundle, it is always equal to 'production'. You cannot override NODE_ENV manually. This prevents developers from accidentally deploying a slow development build to production.
如果你非要在npm start時(shí)區(qū)分環(huán)境,只能自己配置webpack,這時(shí)候NODE_ENV是可以被修改的。
添加回答
舉報(bào)