create react app not picking up .env files?

前端 未结 10 2079
醉话见心
醉话见心 2020-12-12 19:52

I am using create react app to bootstrap my app.

I have added two .env files .env.development and .env.production in the root.

10条回答
  •  一整个雨季
    2020-12-12 20:29

    As of latest react-scripts (3.2.0) it's a simple as putting say

    PORT=4000
    BROWSER=none
    

    in your .env or .env.development file (..etc) which is supposed to be in the root folder.

    It will NOT work with then REACT_APP prefix (the docs are outdated I guess) and it does NOT require any extra npm packages (react-scripts already includes dotenv 6.2.0)

提交回复
热议问题