简体   繁体   中英

Babel-node doesn't transform spread operator on preset env

I'm trying to use babel-node with nodemon for the hot-reloading. I've basically followed this repo .

My dev script in package.json looks like that:

"dev": "nodemon app.js --exec babel-node --presets env"

My .babelrc :

{
  "presets": ["env"]
}

Even though the spread operator is listed as supported by the env preset, when using it with this setup I get a

SyntaxError: Unexpected token

Install plugin-proposal-object-rest-spread .

npm install --save-dev @babel/core @babel/plugin-proposal-object-rest-spread

then change your .babelrc file:

{
  "presets": ["@babel/preset-env"],
  "plugins": ["@babel/plugin-proposal-object-rest-spread"]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM