Dotenv: Fails with create-react-app npm run build

Created on 2 Feb 2018  路  1Comment  路  Source: motdotla/dotenv

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.

Most helpful comment

see #261 dotenv is not intended for browser environments

>All comments

see #261 dotenv is not intended for browser environments

Was this page helpful?
0 / 5 - 0 ratings

Related issues

datasmurfen picture datasmurfen  路  5Comments

shellscape picture shellscape  路  3Comments

ffxsam picture ffxsam  路  4Comments

tikotzky picture tikotzky  路  4Comments

awesomejerry picture awesomejerry  路  4Comments