最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Babel install does not work through npm - Stack Overflow

programmeradmin0浏览0评论

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
[email protected] /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 / for setup instructions.

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

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
[email protected] /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

Share Improve this question asked Apr 15, 2016 at 21:47 akantowordakantoword 3,0549 gold badges28 silver badges49 bronze badges 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. – Mario Tacke Commented 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 Commented May 16, 2016 at 18:17
Add a comment  | 

4 Answers 4

Reset to default 10

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"}

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.

It's easy! you need path babel

For example

sudo ./node_modules/babel-cli/bin/babel.js --watch es6.js --out-file es5.js

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.

发布评论

评论列表(0)

  1. 暂无评论