如何在 create-react-app 中定义 process.env.ENV?

How to define process.env.ENV in create-react-app?

使用 create-react-app 样板的 1.0.5 版本,我开始收到以下警告: *** process.env.ENV is not defined, assuming 'prod' env

我知道如何创建自定义环境变量,但那些需要 REACT_APP_ 前缀。

现在,我发现显示消息是因为 Chrome 的 Grammarly 扩展,禁用它会删除消息。

但是,我想知道如何在不考虑扩展名的情况下解决这个问题。

我知道 Whosebug 上还有 2 个类似的问题,但它们包括使用 Webpack 的解决方案。不幸的是,我无法访问 Webpack,因为我还没有弹出 create-react-app,而且我不打算很快这样做。

有没有办法在 create-react-app 中声明 process.env.ENV 上的环境?

编辑:

这是主要问题。在non-ejectedcreate-react-app?

中定义它在技术上是否可行

Grammarly 扩展是造成这种情况的原因,而不是 React。已通过 Grammarly Support 记录请求,这就是结果

Hailey (Grammarly Support) Jul 6, 11:33 PM PDT

Hi Lankymart,

Thank you for contacting Grammarly Customer Support!

Please rest assured that the technical team is aware of the problem and they are currently working on it.

Unfortunately, this will not be a quick fix and I cannot provide you with an estimated timeframe, as the developers will need some time to analyze the cause of this issue.

I’m going to close this case, but if you have further information regarding this issue, please reply to this email and the case will be re-opened for further investigation. We apologize for any inconvenience caused.

Best wishes, Hailey


Lankymart Jul 6, 12:49 PM PDT

The console window in Chrome is constantly showing the warning - "process.env.ENV is not defined" turning off the extensions removes the error, it is not related a specific website. Already on the internet threads are popping up with people reporting the same issue and the common thread is Grammarly. Has a bug been introduced into the extension perhaps?

Evidence:

https://github.com/facebookincubator/create-react-app/issues/2722#issuecomment-313017403

Website URL: No specific URL issue is a extension bug.