Reputation: 3054
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
Upvotes: 8
Views: 12680
Reputation: 4721
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.
Upvotes: 0
Reputation: 1313
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.
Upvotes: 2
Reputation: 149
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"}
Upvotes: 10
Reputation: 3712
It's easy! you need path babel
For example
sudo ./node_modules/babel-cli/bin/babel.js --watch es6.js --out-file es5.js
Upvotes: 1