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

Cannot npm run build, Error: Could not resolve "@node-rs/argon2-wasm32-wasi" #13061

Open
joshdstockdale opened this issue Nov 26, 2024 · 2 comments

Comments

@joshdstockdale
Copy link

Describe the bug

Trying to build with adapter-cloudflare but I get the following 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.

Versions:
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-cloudflare": "^4.7.4",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0",

I've tried a number of vite.config.ts fixes to mark the package as external but no success:

export default defineConfig({
	plugins: [sveltekit()],
	build: {
		rollupOptions: {
			external: ['@node-rs/argon2-wasm32-wasi']
		}
	},
	ssr: {
		noExternal: ['oslo']
	}
});

Also, my svelte.config.js:

const config = {
	// Consult https://svelte.dev/docs/kit/integrations
	// for more information about preprocessors
	preprocess: vitePreprocess(),

	kit: {
		// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
		// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
		// See https://svelte.dev/docs/kit/adapters for more information about adapters.
		adapter: adapter({
			routes: {
				include: ['/*'],
				exclude: ['<all>']
			},
			platformProxy: {
				environment: undefined,
				experimentalJsonConfig: false,
				persist: false
			}
		}),
		alias: {
			'@/*': './src/lib/*'
		}
	}
};

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-fqgkti

Logs

> 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:///home/stockdale/Sites/deliverys-bane/node_modules/@sveltejs/adapter-cloudflare/index.js:140:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async adapt (file:///home/stockdale/Sites/deliverys-bane/node_modules/@sveltejs/kit/src/core/adapt/index.js:38:2)
    at async finalise (file:///home/stockdale/Sites/deliverys-bane/node_modules/@sveltejs/kit/src/exports/vite/index.js:908:7)
    at async Object.handler (file:///home/stockdale/Sites/deliverys-bane/node_modules/@sveltejs/kit/src/exports/vite/index.js:938:5)
    at async PluginDriver.hookParallel (file:///home/stockdale/Sites/deliverys-bane/node_modules/rollup/dist/es/shared/node-entry.js:20734:17)
    at async Object.close (file:///home/stockdale/Sites/deliverys-bane/node_modules/rollup/dist/es/shared/node-entry.js:21712:13)
    at async build (file:///home/stockdale/Sites/deliverys-bane/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:65466:17)
    at async CAC.<anonymous> (file:///home/stockdale/Sites/deliverys-bane/node_modules/vite/dist/node/cli.js:828:5)

System Info

This also happens on cloudflare trying to build but here's my system:

  System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (4) x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
    Memory: 2.94 GB / 9.62 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 23.3.0 - /usr/local/bin/node
    npm: 10.9.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 131.0.6778.85
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.3.1 
    @sveltejs/adapter-cloudflare: ^4.7.4 => 4.7.4 
    @sveltejs/kit: ^2.0.0 => 2.8.3 
    @sveltejs/vite-plugin-svelte: ^4.0.0 => 4.0.2 
    svelte: ^5.0.0 => 5.2.7 
    vite: ^5.0.3 => 5.4.11

Severity

annoyance

Additional Information

No response

@eltigerchino
Copy link
Member

Please provide a minimal reproduction.

@Devr-pro
Copy link

This a known issue, cloudflare itself doesn't support wasm modules, although don't know this can be fixed within sveltekit, would be very nice if so
For now noble hashes have a js implementation which works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants