npm run build/yarn build does not work in create-react-app apps, when dotenv is a dependency, but npm start (no minify, dev server) works.
https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify
"Some third-party packages don't compile their code to ES5 before publishing to npm. This often causes problems in the ecosystem because neither browsers (except for most modern versions) nor some tools currently support all ES6 features. We recommend to publish code on npm as ES5 at least for a few more years."
> yarn build
yarn run v1.3.2
$ react-scripts build
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file:
./node_modules/dotenv/lib/main.js:23
Read more here: http://bit.ly/2tRViJ9
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
see #261 dotenv is not intended for browser environments
Most helpful comment
see #261 dotenv is not intended for browser environments