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

Does not work in node as advertised #517

Open
xnuk opened this issue Jun 13, 2022 · 4 comments
Open

Does not work in node as advertised #517

xnuk opened this issue Jun 13, 2022 · 4 comments

Comments

@xnuk
Copy link

xnuk commented Jun 13, 2022

With given package.json:

{
	"type": "module",
	"packageManager": "[email protected]",
	"dependencies": { "sql.js": "1.7.0" }
}

Here's the result of node -e 'require("sql.js")()':

(node:31583) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/deps/undici/undici:4813
            throw new TypeError("Failed to parse URL from " + input, { cause: err });
                  ^

TypeError: Failed to parse URL from /home/[redacted]/node_modules/.pnpm/[email protected]/node_modules/sql.js/dist/sql-wasm.wasm
    at new Request (node:internal/deps/undici/undici:4813:19)
    at Agent.fetch2 (node:internal/deps/undici/undici:5505:29)
    ... 4 lines matching cause stack trace ...
    at /home/[redacted]/node_modules/.pnpm/[email protected]/node_modules/sql.js/dist/sql-wasm.js:158:505
    at new Promise (<anonymous>)
    at initSqlJs (/home/[redacted]/node_modules/.pnpm/[email protected]/node_modules/sql.js/dist/sql-wasm.js:22:24)
    at [eval]:1:18 {
  [cause]: TypeError [ERR_INVALID_URL]: Invalid URL
      at new NodeError (node:internal/errors:377:5)
      at URL.onParseError (node:internal/url:563:9)
      at new URL (node:internal/url:643:5)
      at new Request (node:internal/deps/undici/undici:4811:25)
      at Agent.fetch2 (node:internal/deps/undici/undici:5505:29)
      at Object.fetch (node:internal/deps/undici/undici:6332:20)
      at fetch (node:internal/bootstrap/pre_execution:196:25)
      at /home/[redacted]/node_modules/.pnpm/[email protected]/node_modules/sql.js/dist/sql-wasm.js:158:271
      at /home/[redacted]/node_modules/.pnpm/[email protected]/node_modules/sql.js/dist/sql-wasm.js:158:492
      at /home/[redacted]/node_modules/.pnpm/[email protected]/node_modules/sql.js/dist/sql-wasm.js:158:505 {
    input: '/home/[redacted]/node_modules/.pnpm/[email protected]/node_modules/sql.js/dist/sql-wasm.wasm',
    code: 'ERR_INVALID_URL'
  }
}

Node.js v18.3.0
tantaman added a commit to vlcn-io/vlcn-orm that referenced this issue Jun 19, 2022
@jmandzik
Copy link

jmandzik commented Jul 9, 2022

I'm using [email protected] with ES modules and had to explicitly set a path to the wasm binary:

  const wasmBinary = await readFile(new URL("../node_modules/sql.js/dist/sql-wasm.wasm", import.meta.url));
  const SQLJS = await initSql({
    wasmBinary,
  });

Hope that helps!

@sigridjineth
Copy link

@jmandzik I have failed to use the option you mentioned above.
#522

The problem on my side is that the readFile does not allow to take more than one arguments. Which readFile module that you once import?

@xnuk
Copy link
Author

xnuk commented Jul 22, 2022

@sigridjineth

The problem on my side is that the readFile does not allow to take more than one arguments.

Read again carefully, there's two parameters in new URL(..., ...), not await readFile(...)

@Anutrix
Copy link

Anutrix commented Nov 14, 2023

I am facing the same issue on an existing project where the only change I did was in node version to 20.

Seems like Node 18 issue now.
netlify/cli#4610.

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

4 participants