我的控制台一直这样说 “要设置编辑器集成,请将 REACT_EDITOR=atom 之类的内容添加到项目文件夹中的 .env.local 文件中,然后重新启动开发服务器。了解更多信息”
我什至无法在我的 create-react-app 上找到 .env 文件。
提前谢谢您。
最佳答案
Create-React-App 支持 custom environment variables .
文档讨论了如何声明这些变量:
This can be done using two ways: either in your shell or in a .env file. Both of these ways are described in the next few sections.
通过本地环境
第一种方法是将其添加到您的本地环境:
例如,如果您使用的是 bash,请编辑 ~/.bashrc
将 export REACT_APP_EDITOR=atom
添加到底部,然后重新启动终端(或 source ~/.bashrc
)
通过应用程序中的 .env 文件
第二种方法是在应用程序目录的根目录下创建一个 .env
文件,并在其中单行添加变量:
REACT_APP_EDITOR=atom
来自documentation ,这些类型的文件可以被声明并被 Create-React-App 使用:
.env
: Default.
.env.local
: Local overrides. This file is loaded for all environments except test..env.development
,.env.test
,.env.production
: Environment-specific settings.
.env.development.local
,.env.test.local
,.env.production.local
: Local overrides of environment-specific settings.
关于reactjs - REACT_EDITOR=原子错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52856582/