0

From the react-starter-kit, a very popular boilerplate:

This line always fails whenever I try to run or build:

plugins: ['transform-runtime', ...(DEBUG ? [] : ['transform-react-remove-prop-types', 'transform-react-constant-elements', 'transform-react-inline-elements'])]

The error:

> shin-dux@0.0.1 build /Users/justin/WebProjects/self/shin
> babel-node task/run build

/Users/justin/WebProjects/self/shin/task/webpack.config.js:68
        plugins: ['transform-runtime', ...(DEBUG ? [] : ['transform-react-remove-prop-types', 'transform-react-constant-elements', 'transform-react-inline-elements'])]
                                       ^^^

SyntaxError: Unexpected token ...
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:414:25)

I believe other instances of spreading work.

I have tried what I believe is the obvious set of remedies:

  • Delete node_modules and reinstalling
  • Pruning babelrc
  • Using babelrc and not using babelrc (the default is the latter in this case)
  • Varying babel presets
  • Voodoo

This one is driving me nuts because the repository says it builds and I trust them, but it doesn't seem to build for me.

Patrick Roberts
  • 49,224
  • 10
  • 102
  • 153
tacos_tacos_tacos
  • 10,277
  • 11
  • 73
  • 126
  • What does "always fails" mean? It is syntactically correct and works just fine. – zerkms Jul 21 '16 at 01:15
  • @zerkms good question haha – tacos_tacos_tacos Jul 21 '16 at 01:18
  • You have not configured babel properly, see https://babeljs.io/docs/setup/ Alternatively you may simply update to the nodejs >= 6 – zerkms Jul 21 '16 at 01:20
  • @zerkms thanks, I'll take another look, but I've been using `babel` a long, long time without issue... as well as the spread operator... the only thing I have changed recently is reinstalling `mvn` because I had a problem on `OS X` that was unrelated (and it is not `npm` so I don't see why there would be a problem, if anything stuff would use `make` or `gcc` or `llvm` I would think)... the other thing is I don't know if I have ever tried using a conditional within an array with the shorthand quite like that, but I don't see why it would matter – tacos_tacos_tacos Jul 21 '16 at 01:22
  • 1
    Probably babel is configure to transpile only your code, not your webpack configuration files? Are you using any other ES6 features in that particular file? – Bergi Jul 21 '16 at 01:24
  • Strangely enough yes, it was just that particular usage (I was using even the spread operator earlier in the file and that was definitely parsed as it was top level) but I upgraded to node 6 and it is resolved. – tacos_tacos_tacos Jul 21 '16 at 01:28

0 Answers0