-
Notifications
You must be signed in to change notification settings - Fork 153
Module parse failed: Unexpected token (85:10) #21
Comments
I get the same error on compile. |
You both need to correctly configure webpack to handle jsx |
This is a known bug on create-react-app #3856 with importing SVG files () in CSS. I removed the SVG file and converted it to it's I have created a pull request here #22 |
Problem is not having a .svg file in the project, so i dont think the solution is converting it to inline code. |
I beg to differ. Every other file format works fine in my project. Please visit the CRA issue I referenced above. |
I think you have replied to yourself in the issue:
So, you need to correctly configure webpack from the main project (create-react-app webpack config is NOT configured by default to handle .svg files) and add the correct loader to webpack's configuration:
I will probably add this to our Readme because i found myself figuring out this exact piece of code to make the .svg file be correctly handled by webpack in first app i added the component to. |
Hi @IvanLinos as you might already know, CRA does not provide the Webpack config files without ejecting. Technically, the SVG file does not have to be imported in CSS. In this new PR #23 I followed the standard React approach and imported the SVG as a component, and using the I hope you consider this. |
I pretty much consider this solution as a better aproach than having to set the webpack loader (im not a fan of webpack anyway :D). |
Is this bug fix updated in npm https://www.npmjs.com/package/react-images-upload I am not sure how to get the latest version. Could someone help me with this? |
Couldn't get it to work, even with the loader. :( |
Any updates on this issue? I'm on the 1.0.7 version but issue still persists. Thank you! |
hey any update on this issue? i am having same problem. Please request to fix it asap so the module can be used as it is without any webpack config or other stuff |
@karanmartian, I managed to fix the problem. When using version 1.0.7 the issue is fixed. However, for some reason the code was not updated. U had to manually copy the code to my project and now it works. |
@SanderVanCamp i had just installed 1.0.7 like 30 mins ago and then uninstalled it because of this issue. Can you make a new release if this is fixed. because in 1.0.7 its still not working. |
I also have this problem in the latest version (1.0.7). The error message is:
The problem is using The reason for this error (and others), is that source files, rather than bundled files are being distributed. For example, rather than distributing a .js file, an .svg file, and a .css file, a single .js should be distributed with the .svg and .css file bundled within it. While it might be possible for users to do this bundling within their own app's build config, they shouldn't have to. |
Yes, this is the heart of it, and why @SanderVanCamp was able to get it working by manually copying the code into her project (where it would be bundled as part of create react app for example). The solution is to ship a bundled distribution with the npm package. I've been meaning to do this for a while but have been swamped with work from other projects. |
Ok, v1.0.8 is now published, and the pull request #29 is out for review. Try it, and let me know if this is resolved. |
@JakeHartnell v1.0.8 seems to be totally broken, I've left some further details on the PR |
Should work now as of v1.0.95. |
Hey guys, is this issue fixed? I'm using v1.1.99 and I see the following error:
|
@LaKorita it work fine for me in version 1.1.99. I suspect the reason you're having this problem is because you're importing the wrong file. In my case, I'm using ES6 imports
and this imports |
Just found a solution by adding css rule:
and attach your own svg/image. |
I'd love to use your module but using your example that's the error I get on compile, I'm using an app created by the create-react-app module so don't have control over the webpack configuration (I chose not to anyway):
./node_modules/react-images-upload/index.js
Module parse failed: Unexpected token (85:10)
You may need an appropriate loader to handle this file type.
| renderIcon() {
| if (this.props.withIcon) {
| return
| }
| }
The text was updated successfully, but these errors were encountered: