-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
choking on jsx syntax #126
Comments
Update, I've distilled this error to its smallest possible form and cut out gulp entirely: package.json: {
"name": "react-app",
"scripts": {
"build": "browserify ./index.jsx -t babelify -o public/app.js"
},
"dependencies": {
"react": "^0.14.1",
"react-dom": "^0.14.1"
},
"devDependencies": {
"babelify": "^7.0.2",
"browserify": "^12.0.1"
}
} index.js 'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render((
<div>Hello world</div>
), document.querySelector('[data-app]')); Putting these in a directory together, running $ npm run build
> react-app@0.1.0 build /Users/chiel/dev/react-app
> browserify ./index.jsx -t babelify -o public/app.js
SyntaxError: /Users/chiel/dev/react-app/index.jsx: Unexpected token (8:1)
6 |
7 | ReactDOM.render((
> 8 | <div>Hello world</div>
| ^
9 | ), document.querySelector('[data-app]'));
10 |
at Parser.pp.raise (/Users/chiel/dev/react-app/node_modules/babylon/lib/parser/location.js:24:13)
at Parser.pp.unexpected (/Users/chiel/dev/react-app/node_modules/babylon/lib/parser/util.js:91:8)
at Parser.pp.parseExprAtom (/Users/chiel/dev/react-app/node_modules/babylon/lib/parser/expression.js:486:12)
at Parser.pp.parseExprSubscripts (/Users/chiel/dev/react-app/node_modules/babylon/lib/parser/expression.js:244:19)
at Parser.pp.parseMaybeUnary (/Users/chiel/dev/react-app/node_modules/babylon/lib/parser/expression.js:225:19)
at Parser.pp.parseExprOps (/Users/chiel/dev/react-app/node_modules/babylon/lib/parser/expression.js:171:19)
at Parser.pp.parseMaybeConditional (/Users/chiel/dev/react-app/node_modules/babylon/lib/parser/expression.js:153:19)
at Parser.pp.parseMaybeAssign (/Users/chiel/dev/react-app/node_modules/babylon/lib/parser/expression.js:120:19)
at Parser.pp.parseParenAndDistinguishExpression (/Users/chiel/dev/react-app/node_modules/babylon/lib/parser/expression.js:541:26)
at Parser.pp.parseExprAtom (/Users/chiel/dev/react-app/node_modules/babylon/lib/parser/expression.js:443:19)
npm ERR! Darwin 14.1.1
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
npm ERR! node v4.2.0
npm ERR! npm v3.3.6
npm ERR! code ELIFECYCLE
npm ERR! react-app@0.1.0 build: `browserify ./index.jsx -t babelify -o public/app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-app@0.1.0 build script 'browserify ./index.jsx -t babelify -o public/app.js'.
npm ERR! This is most likely a problem with the react-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! browserify ./index.jsx -t babelify -o public/app.js
npm ERR! You can get their info via:
npm ERR! npm owner ls react-app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/chiel/dev/react-app/npm-debug.log Hope this helps. |
Okay did another bit of testing: package.json {
"name": "react-app",
"version": "0.1.0",
"scripts": {
"build": "browserify ./index.jsx -t babelify -o public/app.js"
},
"dependencies": {
"react": "^0.14.1",
"react-dom": "^0.14.1"
},
"devDependencies": {
"babelify": "^6.4.0",
"browserify": "^12.0.1"
}
} index.jsx 'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render((
<div>Hello world</div>
), document.querySelector('[data-app]')); Changed: |
See my most recent comment in #103. |
Under the section titled Plugin Presets from http://babeljs.io/blog/2015/10/29/6.0.0 You probably want Then use it as part of your Babelify options https://github.com/babel/babelify#options |
I feel so damn stupid for not having seen that blog post. Thanks guys! |
blog post link is dead. |
@akisma I fixed the URL up above as well, it shouldn't have had a trailing slash in the URL: http://babeljs.io/blog/2015/10/29/6.0.0 |
@wphampton thank you very much I am using gulp-babel for my build and was getting the same error. |
Summary: Basically you just have to
|
I've just updated
babelify
in order to get rid ofreactify
and hopefully fix the messed up sourcemaps I've been having. However, I was getting some trouble along the lines ofI've installed the latest version of
babelify
(7.0.2), which includesbabel-core
6.0.12.My gulpfile:
And the
./client/scripts/index.jsx
it's choking on:Anything obvious I'm missing, or some config I should be using?
Cheers.
The text was updated successfully, but these errors were encountered: