How to get this to work with ES6 babel-node
See original GitHub issueI realize that the README describes a node-dev.json
file to set extension settings, but it is not clear to me how to get this to work with babel-node.
Currently I’m running my server.js code with the command ./node_modules/.bin/babel-node server/
. When I run the command with node-dev
, node-dev server
, I get the error Unexpected token import
. My node-dev.json
file is like so:
{
"extensions": {
"js": {
"name": "babel/register"
}
}
}
Any suggestions would be very welcome!
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Write ES6 in Node using Babel - DEV Community
Hi all In this short article, Today we will be learning about How to use ES6 syntax(like import from, export default, etc..) with...
Read more >babel/node - Babel.js
babel -node is a CLI that works exactly the same as the Node.js CLI, with the added benefit of compiling with Babel presets...
Read more >How to Setup Babel in Node.js - freeCodeCamp
Let's setup a basic Node app which we will use for this tutorial. Create a new folder. For this tutorial, I'll call mine...
Read more >Writing ES6 in NodeJS using Babel | by Makinde Abass
Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and...
Read more >Using ES6 with BABEL in Node.js - LinkedIn
Before getting started, let me clear Node.js provides support for almost all the ES6 features since Node.js v6 update.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After some playing around, looks like instead of requiring
babel-register
setting this in my.node-dev.json
did the trick:In addition to @amosyuen 's
.node-dev.json
, you might need a.babelrc
in the same directory:P.S.
modules: false
will lead toSyntaxError: Unexpected token import
, so remove it!