Open steventen opened 9 years ago
I don't think there is any reference anywhere in the code to the ws module. Are you sure this issue is related to sql.js?
I also have the same issue, right after installing sql.js
I found a require('ws') in sql.js It is minified but in sublime text i found it line 336
d=new (s?require("ws"):window.WebSocket) Error("WebSocket URL must be in the format ws(s)://address:port"))
Relevant issue : https://github.com/fabiosantoscode/require-emscripten/issues/1
I'm having this issue as well.
I'm using webpack to build my app and I've got the same:
ERROR in ./~/sql.js/js/sql.js
Module not found: Error: Cannot resolve module 'fs' in /Users/thai/Documents/CrossMIP/frame/node_modules/sql.js/js
@ ./~/sql.js/js/sql.js 4:141-154 361:205-218
ERROR in ./~/sql.js/js/sql.js
Module not found: Error: Cannot resolve module 'ws' in /Users/thai/Documents/CrossMIP/frame/node_modules/sql.js/js
@ ./~/sql.js/js/sql.js 337:113-126 342:44-57```
I've fixed the problem by including the sql.js lib manually in my index.html and bypassing webpack or browserify build steps. Works fine so far!
Same here with SystemJS and jspm. See also https://github.com/jspm/jspm-cli/issues/1108
Ok, the problem with the tools you use is that they look at the code for uses of require()
and try to include the dependencies. The tool with which sql.js
is compiled (emscripten) generates conditional require
s, that won't be used in the browser. So either file an issue to the tool you use to process your js for it to be more clever about requires, or to emscripten not to generate these requires. But anyway, I don't think there is something I can do in sql.js.
@kripken : Any idea about this?
Emscripten generates those conditional requires so the same output can run in node and on the web (and elsewhere). We've discussed adding compile-time options to target only one platform, but no one has written a pull request yet.
Here is another fix for the Error: Cannot resolve module 'fs'
error reported by @chauthai - use an externals block in your webpack config to make webpack think the fs module is external like this:
externals: [
{fs: true} // to get sql.js to load - emscripten uses the fs module in certain codepaths we don't use so fake its availability
],
This is my way, to use webpack with sql.js
The line below is added in html file, It seems that we can't build sql.js by webpack.
Hi, I'm using
npm
to installsql.js
. But whenwatchify
try to bundle the app up, it will throw this error:And in the js file, I only have something like this:
I'm using a Windows 7 laptop
I really don't know how can i solve this, thanks