-
Notifications
You must be signed in to change notification settings - Fork 39
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
md5_worker.js fails with 'require is not defined' #7
Comments
Md5FileHasher.prototype.hash = function(blob) { above change worked for me.. I am looking if there is a better solution than giving the path of the file to ParallelHasher since i do not prepfer to copy the 'md5_worker.js' from node_modules folder and copy it to 'assets' folder |
I ended up doing this:
For a more generic solution, the promise could've returned the md5sum instead of appending to formData but the above suited my needs. |
This is still an issue, however a previous commit does work so if you add the following to package.json you might get success
|
Thanks, I've published a new version |
@stakach thanks for the new version, but the webworker still throws |
If you change the line like this does it work? The project that we built this library for hasn't required an update in awhile so whilst we still technically rely on this we're not actively using it at the moment. |
Same issue here : Changing the line from : do resolve the issue. |
fixed in release 1.2.4 |
Thanks for the fix! I downloaded 1.2.4 and successfully hashed files using the ParallelHasher. For example:
Using ParallelHasher let me shrink my hashFile() method substantially as seen here versus my Nov 20th posting.
BTW, I now see that my original code snippet from Nov 6th was flawed because |
@dvandegrift glad to hear that it's working well for you! |
I cloned the repo and copied dist/* to my Angular 4.4.6 application (both under node_modules/ts-md5/dist and src/assets). Then attempted to md5sum a file per the following snippet.
When running the app, Chrome's console shows:
ErrorEvent {isTrusted: true, message: "Uncaught ReferenceError: require is not defined", filename: "http://localhost:4200/assets/md5_worker.js", lineno: 401, colno: 13, …}
Line 401 of md5_worker.js corresponds to this statement:
`var md5_1 = require("./md5");
Is RequireJS meant to be a prerequisite of ts-md5?
As a secondary but related issue:
I had first tried using the latest version (v1.2.2) of ts-md5 from NPM. But it also failed with:
ErrorEvent {isTrusted: true, message: "Uncaught TypeError: Md5.Md5 is not a constructor", filename: "http://localhost:4200/assets/md5_worker.js", lineno: 417, colno: 21, …} Uncaught TypeError: Md5.Md5 is not a constructor at Md5FileHasher.hash (md5_worker.js:417) at global.onmessage (md5_worker.js:502)
Line 417 of md5_worker.js corresponds to:
So md5_worker.js doesn't work whether it's from
a. the head of git: "Uncaught ReferenceError: require is not defined"
b. or NPM: "Uncaught TypeError: Md5.Md5 is not a constructor"
And FYI, the version on NPM is a few months out-of-date compared to git.
I'd appreciate any help getting the file hashing feature of ts-md5 operational in my app.
Thanks,
David
(Sorry for the earlier, empty post. I accidentally hit Enter just as I had started composing this).
The text was updated successfully, but these errors were encountered: