react-pure-component-starter
react-pure-component-starter copied to clipboard
Webpack error "Unexpected token"
Hi,
I just cloned and tried to build the starter kit, but there seems to be an error with webpack.
ERROR in ./source/components/hello/index.js Module parse failed: C:.../source\components\hello\index.js Unexpected token (9:6) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token (9:6)
I have tracked down the cause of this to the webpack.config.dev.js
and webpack.config.prod.js
files. The line that triggers the error is :
include: path.join(__dirname, 'source')
As soon as I remove that line (actually replacing it with an exclude of node_modules
instead), the projet build and runs perfectly.
Do you have any idea what causes this ?
Thanks!
Did you remember to run npm install
?
I ran npm install
but still getting this issue.
Same for me, packages were installed and everything worked once I replaced the include
line in the webpack config.
I ran into the same issue. Thank you @gumarm for adding your workaround.
I too am curious as to what could be causing this.
As a reference, here is the loaders block from my webpack.config.dev.js:
loaders: [{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'stage-0', 'react']
}
}]
I am on a windows machine, node v7.6.0, npm v4.1.2
Thank you Eric for all you do in the tech community!
@higgins1b You can also replace include: path.join(__dirname, 'source')
with an include on the hard-coded path like include: 'path_here'
. I've had this issue with using path.join
on Windows machines before.
I'm open to a PR replacing path.join with an exclude of node_modules, but I'm curious about why path.join doesn't work on Windows. Have any of you searched the Node repo for a corresponding issue and possible resolutions?
Are we sure that the path module is cross platform compatible?
@Burgi0101 It should at least be compatible with Windows according to Node's documentation: https://nodejs.org/api/path.html
@ericelliott I'll search around if I can find a reason as to why it doesn't work, if I don't find anything I'll send a PR for the workaround!
Thanks for your time guys!