banderson / generator-flux-react

A yeoman generator for app based on Facebook's Flux/React architecture
332 stars 35 forks source link

Getting browserify error - Unexpected token (4:13) while parsing file: index.jsx #44

Open explorer2309 opened 8 years ago

explorer2309 commented 8 years ago

After generating the project and running npm start, I ran into this error

[06:33:12] Browserify Error { [SyntaxError: C:/projects/react/gen-flux-demo/src/js/index.jsx: Unexpected token (4:13) while parsing file: C:\projects\react\gen-flux-demo\src\js\index.jsx]
  pos: 99,
  loc: Position { line: 4, column: 13 },
  _babel: true,
  codeFrame: '\u001b[0m  2 | \u001b[36mimport\u001b[39m AppContainer from \u001b[31m\'./components/AppContainer.jsx\'\u001b[39m\u001b[1m;\u001b[22m\n  3 | \n> 4 | React\u001b[1m.\u001b[22mrender\u001b[94m\u001b[1m(\u001b[22m\u001b[39m\u001b[1m<\u001b[22mAppContainer \u001b[1m/\u001b[22m\u001b[1m>\u001b[22m\u001b[1m,\u001b[22m document\u001b[1m.\u001b[22mgetElementById\u001b[94m\u001b[1m(\u001b[22m\u001b[39m\u001b[31m\'main\'\u001b[39m\u001b[94m\u001b[1m)\u001b[22m\u001b[39m\u001b[94m\u001b[1m)\u001b[22m\u001b[39m\u001b[1m;\u001b[22m\n    |              ^\n  5 | \u001b[0m',
  filename: 'C:\\projects\\react\\gen-flux-demo\\src\\js\\index.jsx',

I am getting same error on Linux as well

Any ideas?

loulafripouille commented 8 years ago

Hello, Firstly, thanks for this really good generator!

So, I have the same issue when I try to install the npm package superagent. It is the normal behavior?

Kind regards.

christopherslee commented 8 years ago

i get the same issue on OS X.

christopherslee commented 8 years ago

i was able to follow some instructions here: https://github.com/babel/babelify/issues/126

npm install --save-dev babel-preset-es2015
npm install --save-dev babel-preset-react

then edit .babelrc

{
  "presets": ["es2015", "react"]
}
madebysquares commented 8 years ago

:+1: this worked for me thanks @christopherslee

BrunoQuaresma commented 8 years ago

Works for me too. Thanks @christopherslee

banderson commented 8 years ago

Thanks @christopherslee and friends! I just published 0.4.6 which should include this change. Let me know if you run into any issues.

klvenky commented 7 years ago

Hi all, I have come across this when I was trying to do something on react with es6. Even I followed the same babel config

{
  "presets": [
    [
      "es2015"
    ],
    "react"
  ],
  "plugins": [
    "react-hot-loader/babel"
  ]
}

However though It didn't work for me. It shows that there is an unexpected token which I found out to be "="