0

I have been following the react: up and running book by stoyan stephanov. Chapter 5. I am stuck at the command:

babel --presets react,es2015 js/source -d js/build

result: es2015 does not exist.

But when I try: babel --presets react js/source -d js/build

it works as expected in the book.

And then I write: babel --presets react,es2015 js/source -d js/build

result: Syntax error at app.js. Unexpected token before h1 tag.

App.js code

'use strict';

import React from 'react';
import ReactDOM from 'react-dom';
import Logo from './components/Logo';

ReactDOM.render(
  <h1>
    Welcome to the  app!
  </h1>,
  document.getElementById('app')
);

1 Answer 1

1

All optional presets must be installed manually, as far as I know:

npm install --save-dev babel-preset-es2015

P.S. Here are some additional data on issue.

Sign up to request clarification or add additional context in comments.

3 Comments

You'd want to --saveDev in this instance as it's purely a dev tool to transpile back to old skool JS.
Thank you for the quick response fellows. I tried the command mentioned by @ankhzet but later tried the command: babel --presets react,es2015 js/source -d js/build. Unfortunately the same message. Am i missing something?
@ZahirJunejo, only suggestion I can give, try reverse order for presets: babel --presets es2015,react js/source -d js/build. The order in which transformations are applied is actually important when .babelrc is used, maybe it's also applies to cli

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.