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

SvelteKit 2 & Cloudflare Page: Could not resolve "@node-rs/argon2-wasm32-wasi" #862

Open
Shyrogan opened this issue Jul 23, 2024 · 6 comments

Comments

@Shyrogan
Copy link

I made a project to reproduce the error here:
https://github.com/Shyrogan/sveltekit-argon2-cf-error

> Using @sveltejs/adapter-cloudflare
✘ [ERROR] Could not resolve "@node-rs/argon2-wasm32-wasi"

    node_modules/@node-rs/argon2/browser.js:1:14:
      1 │ export * from '@node-rs/argon2-wasm32-wasi'
        ╵               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "@node-rs/argon2-wasm32-wasi" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.


error during build:
Error: Bundling with esbuild failed with 1 error
    at adapt (file:///Users/sebastienvial/Documents/transitions.ag/cloudflare-pages-sveltekit/node_modules/@sveltejs/adapter-cloudflare/index.js:134:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async adapt (file:///Users/sebastienvial/Documents/transitions.ag/cloudflare-pages-sveltekit/node_modules/@sveltejs/kit/src/core/adapt/index.js:38:2)
    at async finalise (file:///Users/sebastienvial/Documents/transitions.ag/cloudflare-pages-sveltekit/node_modules/@sveltejs/kit/src/exports/vite/index.js:890:7)
    at async Object.handler (file:///Users/sebastienvial/Documents/transitions.ag/cloudflare-pages-sveltekit/node_modules/@sveltejs/kit/src/exports/vite/index.js:920:5)
    at async PluginDriver.hookParallel (file:///Users/sebastienvial/Documents/transitions.ag/cloudflare-pages-sveltekit/node_modules/rollup/dist/es/shared/node-entry.js:19730:17)
    at async Object.close (file:///Users/sebastienvial/Documents/transitions.ag/cloudflare-pages-sveltekit/node_modules/rollup/dist/es/shared/node-entry.js:20665:13)
    at async build (file:///Users/sebastienvial/Documents/transitions.ag/cloudflare-pages-sveltekit/node_modules/vite/dist/node/chunks/dep-D8YhmIY-.js:65760:17)
    at async CAC.<anonymous> (file:///Users/sebastienvial/Documents/transitions.ag/cloudflare-pages-sveltekit/node_modules/vite/dist/node/cli.js:828:5)
@adumesny
Copy link

adumesny commented Oct 31, 2024

I have the same issue with esbuild (webpack was fine) using node v22 not finding @node-rs/jieba-wasm32-wasi

if I use an older v1.19.0 version that gives a bit more info (about 'path' and then the correct bit jieba-win32-x64-msvc)

X [ERROR] Could not resolve "path"

    node_modules/@node-rs/jieba/index.js:11:12:
      11 │ } = require('path');
         ╵             ~~~~~~

  The package "path" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


X [ERROR] No loader is configured for ".node" files: node_modules/@node-rs/jieba-win32-x64-msvc/jieba.win32-x64-msvc.node

    node_modules/@node-rs/jieba/index.js:104:36:
      104 │ ...        nativeBinding = require('@node-rs/jieba-win32-x64-msvc');

@Brooooooklyn
Copy link
Member

need to install @node-rs/jieba-wasm32-wasi or @node-rs/argon2-wasm32-wasi manually: npm i @node-rs/argon2-wasm32-wasi

@adumesny
Copy link

adumesny commented Nov 1, 2024

I had tried that and didn't work, I get (on windows x64) this error. Looks like a 32bit image or something to me.... with the older 1.9.0 version it does install @node-rs/jieba-win32-x64-msvc (or linux version on our build machine) but then esbuild doesn't know how to load .node files.

> yarn add @node-rs/jieba-wasm32-wasi
error @node-rs/jieba-wasm32-wasi@2.0.0: The CPU architecture "x64" is incompatible with this module.
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

@Brooooooklyn
Copy link
Member

@adumesny see #792 (comment) for the context

@adumesny
Copy link

adumesny commented Nov 3, 2024

sure I can force install it locally once, but then anytime someone runs yarn it will give this error, so that is not a working option.

> yarn add @node-rs/jieba-wasm32-wasi --ignore-platform

add it, and create some other module error I will ignore, but then

> yarn
error @node-rs/jieba-wasm32-wasi@2.0.0: The CPU architecture "x64" is incompatible with this module.
error Found incompatible module.

Should I just stick to v1.9.0 and figure out a way to have esbuild load .node extension, or possibly stubb this code out since we do no need to support chineese at this time but a module we use depends on it.

@Brooooooklyn thanks for the update.

@adumesny
Copy link

adumesny commented Nov 4, 2024

and even when I force add I still get these errors, so back to square one

X [ERROR] No loader is configured for ".wasm" files: node_modules/@node-rs/jieba/node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasm32-wasi.wasm?url

    node_modules/@node-rs/jieba/node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasi-browser.js:2:22:
      2 │ import __wasmUrl from './jieba.wasm32-wasi.wasm?url';
        ╵                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


X [ERROR] Top-level await is not available in the configured target environment ("chrome128.0", "edge128.0", "firefox115.0", "ios17.0", "safari17.0" + 5 overrides)

    node_modules/@node-rs/jieba/node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasi-browser.js:12:19:
      12 │ const __wasmFile = await fetch(__wasmUrl).then(res => res.arrayBuf...
         ╵                    ~~~~~


X [ERROR] This require call is not allowed because the transitive dependency "node_modules/@node-rs/jieba/node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasi-browser.js" contains a top-level await

    node_modules/lunr-languages/lunr.zh.js:33:37:
      33 │     module.exports = factory(require('@node-rs/jieba'));
         ╵                                      ~~~~~~~~~~~~~~~~

  The file "node_modules/@node-rs/jieba/browser.js" imports the file "node_modules/@node-rs/jieba/node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasi-browser.js" here:

    node_modules/@node-rs/jieba/browser.js:1:14:
      1 │ export * from '@node-rs/jieba-wasm32-wasi';
        ╵               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  The top-level await in "node_modules/@node-rs/jieba/node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasi-browser.js" is here:

    node_modules/@node-rs/jieba/node_modules/@node-rs/jieba-wasm32-wasi/jieba.wasi-browser.js:12:19:
      12 │ const __wasmFile = await fetch(__wasmUrl).then(res => res.arrayBuf...

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

3 participants