Wednesday, 5 April 2017

How to setup babel-cli to run react-native ES6 JavaScript code on command line?

My goal is to test & debug JavaScript code ( not JSX ) in the command line.

This is what I tried:

Install babel-cli
   npm install --save-dev babel-cli

File: .babelrc ( in project root )
{
  "presets": ["react-native"]
}

Run sandbox:
./node_modules/.bin/babel-node app/components/sandbox.js

I get the following run-time error:

   /react-native/myapp/source/node_modules/react-native/Libraries/react-native/react-native.js:15
    if (__DEV__) {
        ^
        ReferenceError: __DEV__ is not defined

What am I missing?



via Ed of the Mountain

No comments:

Post a Comment