When I use requirejs in a Web page to load jszip.js, like so:
require(['public/javascripts/jszip'], function(file){
window.JSZip = file;
});
I get this error: "Error: Module name "stream" has not been loaded yet for context: _. Use require([])"
The line of code causing the error in jszip.js is: module.exports = require("stream");
The stream module is a nodejs module. I don't have the stream module in my web app, hence the error.
It appears that using requirejs to load jszip leads jszip to assume it's being loaded in a nodejs app. So it initializes itself as if in a nodejs environment. But I am loading it in a web page using requirejs.
Also, the error occurs when using the new operator to load jszip, like so (if requirejs is also loaded in page):
var zip = new JSZip();
Is it possible to load jszip using requirejs in a web app that runs in the browser and not in nodejs? My app is an existing app that uses requirejs, so I have no choice. As is, without modifying jszip, there is not a way to use jszip in a web app, without a requirejs error, in an app that uses requirejs in the browser.
When I use requirejs in a Web page to load jszip.js, like so:
I get this error: "Error: Module name "stream" has not been loaded yet for context: _. Use require([])"
The line of code causing the error in jszip.js is:
module.exports = require("stream");The stream module is a nodejs module. I don't have the stream module in my web app, hence the error.
It appears that using requirejs to load jszip leads jszip to assume it's being loaded in a nodejs app. So it initializes itself as if in a nodejs environment. But I am loading it in a web page using requirejs.
Also, the error occurs when using the new operator to load jszip, like so (if requirejs is also loaded in page):
var zip = new JSZip();Is it possible to load jszip using requirejs in a web app that runs in the browser and not in nodejs? My app is an existing app that uses requirejs, so I have no choice. As is, without modifying jszip, there is not a way to use jszip in a web app, without a requirejs error, in an app that uses requirejs in the browser.