question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Using `babel-preset-react-app` requires that you specify `NODE_ENV` or `BABEL_ENV`

See original GitHub issue

Can you reproduce the problem with latest npm?

yes

Can you still reproduce it?

yes

Description

When creating a new react app with create-react-app without doing anything, only running yarn start gives the following error :

Failed to compile.
./src/index.js
Module build failed: Error: Using `babel-preset-react-app` requires that you specify `NODE_ENV` or `BABEL_ENV` environment variables. Valid values are "development", "test", and "production". Instead, received: "undefined".
 (While processing preset: "/Users/nboisvert/Git/memberzone/node_modules/babel-preset-react-app/index.js")
    at Array.map (native)

Expected behavior

Run the template React app

Actual behavior

Displays : image

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected):
memberzone@0.1.0 /Users/nboisvert/Git/memberzone
└── react-scripts@1.0.6
  1. node -v: v6.2.1
  2. npm -v: 4.6.1

Then, specify:

  1. Operating system: macOS Sierrra 10.12.5
  2. Browser and version: Google Chrome Version 58.0.3029.110 (64-bit)

Reproducible Demo

Didn’t add anything. Fresh install

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

6reactions
heshamelmasry77commented, Nov 23, 2017

to fix this you need to do that : create a .babelrc file and then add this following code in it.

{
  "presets": [
    "react",
    "es2015",
    "stage-2"
  ]
}

i am using es2015 and stage-2 and for your : scripts : start.js add this :

process.env.BABEL_ENV = 'development';
process.env.NODE_ENV = 'development';

you can create a development , test, build one. my advice to you and i found that it is good to understand what is happening is to eject the react project.

6reactions
gaearoncommented, May 27, 2017

Please try react-scripts@1.0.7 (or create a new project). Should hopefully fix the issue.

https://github.com/facebookincubator/create-react-app/releases/tag/v1.0.7

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to provide `babel-preset-react-app` env variables?
Error : Using babel-preset-react-app requires that you specify NODE_ENV or BABEL_ENV environment variables. Valid values are "development", "test ...
Read more >
Using `babel-preset-react-app` requires that you specify ...
Error : [BABEL] xxx.js: Using `babel-preset-react-app` requires that you specify `NODE_ENV` or `BABEL_ENV` environment variables. 毛毛. 作者 毛毛 310篇文章.
Read more >
[Vim/Ale] Parsing error: [BABEL] /<project>/src/options.js ...
This is a Chrome extension project (manifest v3) built with React. ... `babel-preset-react-app` requires that you specify `NODE_ENV` or ...
Read more >
Using `babel-preset-react-app` requires that you specify ...
Using `babel-preset-react-app` requires that you specify `NODE_ENV` or `BABEL_ENV` environment varia.
Read more >
error:Using `babel-preset-react-app` requires that you ... - 掘金
Using `babel-preset-react-app` requires that you specify `NODE_ENV` or `BABEL_ENV` environment...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found