Phantom Engine
Phantom Engine

Reputation: 121

babel-preset-react-app not picking up environment variables

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:"C:\Users\mitch\OneDrive\Development\Git\react-seed\node_modules\babel-preset-react-app\index.js") at Array.map (native)

I keep getting the above error no matter how many weird and wonderful ways I try to set either the environment or the environment variables since updating my react-app and I even get this on a fresh app created from the 'create-react-app' scripts - What am I clearly doing wrong?

Upvotes: 12

Views: 11564

Answers (3)

Gaurav Mogha
Gaurav Mogha

Reputation: 400

{
  "scripts": {
    "build": "export NODE_ENV=development && babel src -d lib",
    "build-prod": "export NODE_ENV=production && babel src -d lib"
  }
}

Upvotes: -1

Sgedda
Sgedda

Reputation: 1531

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: "development "

Ran into a similar problem and noticed that a space character messed things up with this configuration:

SET NODE_ENV=development && node server/bootstrap.js

//Changed to this:
SET NODE_ENV=development&&node server/bootstrap.js

Upvotes: 6

dsdenes
dsdenes

Reputation: 1035

I do it in my package.json:

{
  "scripts": {
    "build": "NODE_ENV=development babel src -d lib",
    "build-prod": "NODE_ENV=production babel src -d lib"
  }
}

Upvotes: 11

Related Questions