Skip to content
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

Uncaught Error: Cannot find module "script!sql.js" #19

Closed
yakhinvadim opened this issue Jun 18, 2017 · 8 comments
Closed

Uncaught Error: Cannot find module "script!sql.js" #19

yakhinvadim opened this issue Jun 18, 2017 · 8 comments

Comments

@yakhinvadim
Copy link
Contributor

I tried to fix the issue #18 by checking if window object is present.
I added

 || typeof window !== 'undefined'

here: https://github.com/ewnd9/anki-apkg-export/blob/master/src/index.js#L8
and here: https://github.com/ewnd9/anki-apkg-export/blob/master/src/exporter.js#L56
(but in dist folder) and it worked. But I faced an error:
image
Unfortunately, I don't understand the cause of the error. script and raw loaders are installed. Maybe the reason is in webpack config somewhere, but can't edit it.

Do you have an idea what can cause this error and how I could fix it?

In case you'd like to try it yourself, I created a minimal representation of this case in this repo:
https://github.com/yakhinvadim/anki-apkg-export-error
This is app, created with create-react-app. My changes for this case are in this commit yakhinvadim/anki-apkg-export-error@4fec6c2

@ewnd9
Copy link
Member

ewnd9 commented Jun 18, 2017

The reason behind the error is due to deprecation of short loader syntax (should be script-loader in webpack@2)

However, after I manually changed that, I see the following

image

I suggest starting with the browser example from this repo and gradually add dependencies/config from ejected create-react-app to find what's wrong.

@yakhinvadim
Copy link
Contributor Author

Thanks for the help. I'll try to fix it and send a PR.

@yakhinvadim
Copy link
Contributor Author

yakhinvadim commented Jun 24, 2017

For some reason, there are several very similar "filesaver" packages on npm (in order of popularity)

You are using the third one and it works fine for your cases, but its readme says to use the first. I installed it and my error has gone :)

I tried the most popular package with your examples and it doesn't work correctly for browser-media-file-input (card doesn't have the image from input). I've sent you a PR #23, where I switched the filesaverjs for file-saver, so if you wanted to, you could investigate why it doesn't work as expected. But it breaks your examples, so it's ok if you decline it.

I've also sent a PR #22, which fixes short-loader syntax.

@ewnd9
Copy link
Member

ewnd9 commented Jun 24, 2017

Yeah, I've seen deprecation messages from filesaver when tried your create-react-app example, but didn't have time to check.

I installed it and my error has gone :)

You are talking about the deprecate error in #19 (comment) right?

I'm going to investigate the package from your pr later, thanks for help 👍

@yakhinvadim
Copy link
Contributor Author

You are talking about the deprecate error in #19 (comment) right?

Sorry, I wasn't clear. Yes, I was talking about deprecate error.

@ewnd9
Copy link
Member

ewnd9 commented Jun 24, 2017

Apparently the most popular filesaver wasn't on npm at the time I published the first version (package.json only added in May 26, 2016 eligrey/FileSaver.js@cb8e076)

@ewnd9
Copy link
Member

ewnd9 commented Jun 24, 2017

I've checked locally your branch and turned out you forgot to rebase with my latest changes, the error in examples was due to very old anki-apkg-export dependency, see cc9d686

Thanks again, not only the package now is future-proof, but I also gained the knowledge about non-obvious (for me) deprecating behavior in some environments, appreciate that ✌️


I've published v3.2.0, let me know if it works ok for your project.

@yakhinvadim
Copy link
Contributor Author

Everything's ok now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants