7

I'm trying to install ES6 through Babel by following this guy but I'm getting a mistake from my terminal. This is what I see after doing npm install --global babel

/usr/local/bin/babel -> /usr/local/lib/node_modules/babel/cli.js
/usr/local/bin/babel-node -> /usr/local/lib/node_modules/babel/cli.js
/usr/local/bin/babel-external-helpers -> /usr/local/lib/node_modules/babel/cli.js
babel@6.5.2 /usr/local/lib/node_modules/babel

When I type in babel-node

You have mistakenly installed the `babel` package, which is a no-op in Babel 6.
Babel's CLI commands have been moved from the `babel` package to the `babel-cli` package.

    npm uninstall babel
    npm install babel-cli

See http://babeljs.io/docs/usage/cli/ for setup instructions.

I get the same response as before when I try npm uninstall babel

2
  • 1
    What about the message do you not understand? Babel recently upgraded to 6 which changed a few things. You can either install the cli like the message suggests or possibly use an older version of babel. Btw, ES6 is not something you install. Apr 16, 2016 at 0:58
  • what does it mean for the package to be a no-op? what is a no-op? i get the same error message when i try to npm uninstall babel, so i can't do what the prompt tells me to do
    – akantoword
    May 16, 2016 at 18:17

4 Answers 4

8

Use this.

npm install --global babel-cli

This installs it globally and works perfectly. And check your package.json, whether babel-cli node is created under dev dependencies:

"devDependencies": {"babel-cli": "^6.14.0"}
2

some version mismatch for sure. I following the instruction of removing babel and then installing babel cli to local and global.

npm uninstall babel 
npm install --global babel-cli (this alone was   not enough) 
npm install babel-cli

It worked fine after that.

1

It's easy! you need path babel

For example

sudo ./node_modules/babel-cli/bin/babel.js --watch es6.js --out-file es5.js
3
  • what would this do exactly? this would only work if i have babel on a project and not locally, right?
    – akantoword
    May 16, 2016 at 18:18
  • yeah! but you can change path babel May 16, 2016 at 18:21
  • how does this work if npm isn't even letting me install babel?
    – akantoword
    May 16, 2016 at 18:29
0

To run my Node.js application with ES6 features enabled, this is what I did !.

In my package.json file I have added 2 devDependencies.

  "devDependencies": {
    "babel-cli": "^6.0.0",
    "babel-preset-es2015": "^6.0.0"
  }

And then writing babel-node --presets es2015 app.js in the terminal did the job well.

Here app.js is the main file in the project some people may call it server.js or `index.js.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.