webpack: Webpack's Acorn Dependency Choking on JSX on Node 6.0+ (Babel-Loader Not Being Loaded Correctly?)
JSX code for me that works on Node 5.11 is failing with Node 6. It appears to be a problem with the Acorn module Webpack is relying on.
ERROR in ./src/index.js Module parse failed: c:\code\app\src\index.js Unexpected token (17:2) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token (17:2) at Parser.pp.raise (C:\code\canopy-app\node_modules\webpack\node_modules\acorn\dist\acorn.js:920:13) at Parser.pp.unexpected (C:\code\canopy-app\node_modules\webpack\node_modules\acorn\dist\acorn.js:1483:8) at Parser.pp.parseExprAtom (C:\code\canopy-app\node_modules\webpack\node_modules\acorn\dist\acorn.js:330:12) at Parser.pp.parseExprSubscripts (C:\code\canopy-app\node_modules\webpack\node_modules\acorn\dist\acorn.js:225:19) at Parser.pp.parseMaybeUnary (C:\code\canopy-app\node_modules\webpack\node_modules\acorn\dist\acorn.js:204:17) at Parser.pp.parseExprOps (C:\code\canopy-app\node_modules\webpack\node_modules\acorn\dist\acorn.js:151:19)
at Parser.pp.parseMaybeConditional (C:\code\canopy-app\node_modules\webpack\node_modules\acorn\dist\acorn.js:133:19) at Parser.pp.parseMaybeAssign (C:\code\canopy-app\node_modules\webpack\node_modules\acorn\dist\acorn.js:110:19) at Parser.pp.parseExprList (C:\code\canopy-app\node_modules\webpack\node_modules\acorn\dist\acorn.js:657:23) at Parser.pp.parseSubscripts (C:\code\canopy-app\node_modules\webpack\node_modules\acorn\dist\acorn.js:249:29)
@ multi main
Extra info:
Webpack version: 1.13.0
Referenced Acorn version within Webpack’s node_modules: 3.1.0
Chunk of code the parser is choking on:
render( <Root />, document.getElementById('root') );
It seems to just choke on basic JSX syntax. However, if I downgrade Node back to 5.11 it works as it should.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (1 by maintainers)
@lmanco You are right. And I watch the program:
Here, code shows that webpack will test the
include
. So, if the value ofinclude
on different OS will make the result different. You can click issue#19 to learn more. At last, I recommend to replace__dirname + '/app'
withpath.resolve(__dirname, 'app')
.Good luck 😃
I’m still getting this error regardless of what version of Node I use. I have done
npm cache clean
after removing node_modules and changing versions every time. Does anyone have any more information on this?My webpack config is:
My .babelrc is:
Any help with this would be greatly appreciated.
UPDATE:
Changing my include to
__dirname + '/app'
seems to have fixed this. It’s working fine with Node 6.2.2. Hopefully this might help anyone else who comes across this.@Loopiezlol I am also using Gulp and webpack and have the same issues. Did you try adding the webpack lib into the arguments of the webpack-stream? Should look like this:
Found out this can also be related to
webpack-stream
.Initially, I was running webpack from my gulp file:
By installing
webpack
as a dependency to my folder, the paths were the errors were thrown were under:When switching to
webpack
with nogulp
support (usingwebpack
instead ofwebpack-stream
basically) my problems were solved. Possibly becausewebpack-stream
uses version^1.12.9
?Encountered this bug while trying to implement SendBird JavaScript library.