kit: Module Not Found in Build Production w/ Netlify
Describe the bug
After I updated Svelte to the latest update, I encountered an error that I can’t seem to overcome when deploying to Netlify, from code written by Sveltekit in the .netlify foldered.
I have all the latest versions of - Svelte, Sveltekit, SvelteKit Netlify Adapter, and llhttp.
Everytime I try to deploy, I get this error:
7:21:10 AM: ────────────────────────────────────────────────────────────────
7:21:10 AM: 2. Functions bundling
7:21:10 AM: ────────────────────────────────────────────────────────────────
7:21:10 AM:
7:21:10 AM: Packaging Functions from .netlify/functions-internal directory:
7:21:10 AM: - render.js
7:21:10 AM:
7:21:11 AM:
7:21:11 AM: ────────────────────────────────────────────────────────────────
7:21:11 AM: Dependencies installation error
7:21:11 AM: ────────────────────────────────────────────────────────────────
7:21:11 AM:
7:21:11 AM: Error message
7:21:11 AM: A Netlify Function failed to require one of its dependencies.
7:21:11 AM: Please make sure it is present in the site's top-level "package.json".
7:21:11 AM: In file "/opt/build/repo/app/.netlify/functions-internal/render.js"
7:21:11 AM: Cannot find module './llhttp/llhttp_simd.wasm.js' from '/opt/build/repo/app/.netlify'
I’ve installed llhttp in the top level package.json. I went digging, and in the file “.netlify/shims.js” on line 3396, it trys:
mod = await WebAssembly.compile(Buffer.from(require('./llhttp/llhttp_simd.wasm.js'), 'base64'));
This is where the error is coming from, I believe.
My code is hosted on replit: https://replit.com/@AcousticTypewriter911/AudreyTk#app And Github:https://github.com/INTERNAL-ERROR/AudreyTk
Would welcome and advice on how to correct this error. I can “npm run build && npm run preview” without error, this only happens in production.
Reproduction
I have followed every step in how to install Svelte & Sveltekit, and how to run it on Netlify. I’m not sure where I went wrong.
Logs
Full log:
*7:20:38 AM: Build ready to start
7:20:51 AM: build-image version: 72a309a113b53ef075815b129953617827965e48 (focal)
7:20:51 AM: build-image tag: v4.8.2
7:20:51 AM: buildbot version: 515e5c33287d8b909c004fcf2e460e8645e8c1c6
7:20:51 AM: Fetching cached dependencies
7:20:51 AM: Finished downloading cache in 89.469431ms
7:20:51 AM: Starting to extract cache
7:20:51 AM: Finished extracting cache in 5.440011ms
7:20:51 AM: Finished fetching cache in 95.068862ms
7:20:51 AM: Starting to prepare the repo for build
7:20:52 AM: Preparing Git Reference refs/heads/master
7:20:52 AM: Parsing package.json dependencies
7:20:53 AM: Different build dir detected, going to use the one specified in the Netlify configuration file: 'app' versus 'app/' in the Netlify UI
7:20:53 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'app/build' versus 'build/' in the Netlify UI
7:20:53 AM: Starting build script
7:20:53 AM: Installing dependencies
7:20:53 AM: Python version set to 2.7
7:20:54 AM: v16.15.1 is already installed.
7:20:55 AM: Now using node v16.15.1 (npm v8.11.0)
7:20:55 AM: Started restoring cached build plugins
7:20:55 AM: Finished restoring cached build plugins
7:20:55 AM: Attempting ruby version 2.7.2, read from environment
7:20:56 AM: Using ruby version 2.7.2
7:20:56 AM: Using PHP version 8.0
7:20:56 AM: No npm workspaces detected
7:20:56 AM: Started restoring cached node modules
7:20:56 AM: Finished restoring cached node modules
7:20:57 AM: Installing NPM modules using NPM version 8.11.0
7:20:57 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
7:20:57 AM: npm WARN config location in the cache, and they are managed by
7:20:57 AM: npm WARN config [`cacache`](http://npm.im/cacache).
7:20:57 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
7:20:57 AM: npm WARN config location in the cache, and they are managed by
7:20:57 AM: npm WARN config [`cacache`](http://npm.im/cacache).
7:21:00 AM: > app@0.0.1 prepare
7:21:00 AM: > svelte-kit sync
7:21:00 AM: added 130 packages, and audited 131 packages in 3s
7:21:00 AM: 10 packages are looking for funding
7:21:00 AM: run `npm fund` for details
7:21:00 AM: found 0 vulnerabilities
7:21:00 AM: NPM modules installed
7:21:01 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
7:21:01 AM: npm WARN config location in the cache, and they are managed by
7:21:01 AM: npm WARN config [`cacache`](http://npm.im/cacache).
7:21:01 AM: Started restoring cached go cache
7:21:01 AM: Finished restoring cached go cache
7:21:01 AM: Installing Go version 1.17 (requested 1.17)
7:21:06 AM: unset GOOS;
7:21:06 AM: unset GOARCH;
7:21:06 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
7:21:06 AM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
7:21:06 AM: go version >&2;
7:21:06 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
7:21:06 AM: go version go1.17 linux/amd64
7:21:06 AM: Installing missing commands
7:21:06 AM: Verify run directory
7:21:08 AM:
7:21:08 AM: ────────────────────────────────────────────────────────────────
7:21:08 AM: Netlify Build
7:21:08 AM: ────────────────────────────────────────────────────────────────
7:21:08 AM:
7:21:08 AM: ❯ Version
7:21:08 AM: @netlify/build 27.3.0
7:21:08 AM:
7:21:08 AM: ❯ Flags
7:21:08 AM: baseRelDir: true
7:21:08 AM: buildId: 62bf02b6c21b8c000951f346
7:21:08 AM: deployId: 62bf02b6c21b8c000951f348
7:21:08 AM:
7:21:08 AM: ❯ Current directory
7:21:08 AM: /opt/build/repo/app
7:21:08 AM:
7:21:08 AM: ❯ Config file
7:21:08 AM: /opt/build/repo/app/netlify.toml
7:21:08 AM:
7:21:08 AM: ❯ Context
7:21:08 AM: production
7:21:08 AM:
7:21:08 AM: ────────────────────────────────────────────────────────────────
7:21:08 AM: 1. build.command from netlify.toml
7:21:08 AM: ────────────────────────────────────────────────────────────────
7:21:08 AM:
7:21:08 AM: $ npm run build
7:21:08 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
7:21:08 AM: npm WARN config location in the cache, and they are managed by
7:21:08 AM: npm WARN config [`cacache`](http://npm.im/cacache).
7:21:08 AM: > app@0.0.1 build
7:21:08 AM: > svelte-kit build
7:21:09 AM: vite v2.9.13 building for production...
7:21:09 AM: transforming...
7:21:09 AM: ✓ 13 modules transformed.
7:21:09 AM: rendering chunks...
7:21:10 AM: Client build completed. Wrote 5 chunks and 1 assets
7:21:10 AM: Building server
7:21:10 AM: .svelte-kit/output/client/_app/immutable/manifest.json 1.14 KiB
7:21:10 AM: .svelte-kit/output/client/_app/immutable/start-f5f0626d.js 23.04 KiB / gzip: 8.73 KiB
7:21:10 AM: .svelte-kit/output/client/_app/immutable/layout.svelte-8187eef2.js 0.53 KiB / gzip: 0.35 KiB
7:21:10 AM: .svelte-kit/output/client/_app/immutable/error.svelte-61066a60.js 1.56 KiB / gzip: 0.75 KiB
7:21:10 AM: .svelte-kit/output/client/_app/immutable/pages/index.svelte-b63b29a9.js 0.80 KiB / gzip: 0.47 KiB
7:21:10 AM: .svelte-kit/output/client/_app/immutable/chunks/index-c3650d4a.js 6.84 KiB / gzip: 2.79 KiB
7:21:10 AM: vite v2.9.13 building SSR bundle for production...
7:21:10 AM: transforming...
7:21:10 AM: ✓ 11 modules transformed.
7:21:10 AM: Generated an empty chunk: "hooks"
7:21:10 AM: rendering chunks...
7:21:10 AM: .svelte-kit/output/server/manifest.json 1.09 KiB
7:21:10 AM: .svelte-kit/output/server/index.js 73.00 KiB
7:21:10 AM: .svelte-kit/output/server/entries/fallbacks/layout.svelte.js 0.24 KiB
7:21:10 AM: .svelte-kit/output/server/entries/fallbacks/error.svelte.js 0.72 KiB
7:21:10 AM: .svelte-kit/output/server/entries/pages/index.svelte.js 0.32 KiB
7:21:10 AM: .svelte-kit/output/server/chunks/index-5f038599.js 2.31 KiB
7:21:10 AM: .svelte-kit/output/server/chunks/hooks-1c45ba0b.js 0.00 KiB
7:21:10 AM: Prerendering
7:21:10 AM: Run npm run preview to preview your production build locally.
7:21:10 AM: (node:1552) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time
7:21:10 AM: (Use `node --trace-warnings ...` to show where the warning was created)
7:21:10 AM:
7:21:10 AM: > Using @sveltejs/adapter-netlify
7:21:10 AM: Publishing to "build"
7:21:10 AM: Copying assets...
7:21:10 AM: Writing custom headers...
7:21:10 AM: Generating serverless functions...
7:21:10 AM: Writing redirects...
7:21:10 AM: ✔ done
7:21:10 AM:
7:21:10 AM: (build.command completed in 2.4s)
7:21:10 AM:
7:21:10 AM: ────────────────────────────────────────────────────────────────
7:21:10 AM: 2. Functions bundling
7:21:10 AM: ────────────────────────────────────────────────────────────────
7:21:10 AM:
7:21:10 AM: Packaging Functions from .netlify/functions-internal directory:
7:21:10 AM: - render.js
7:21:10 AM:
7:21:11 AM:
7:21:11 AM: ────────────────────────────────────────────────────────────────
7:21:11 AM: Dependencies installation error
7:21:11 AM: ────────────────────────────────────────────────────────────────
7:21:11 AM:
7:21:11 AM: Error message
7:21:11 AM: A Netlify Function failed to require one of its dependencies.
7:21:11 AM: Please make sure it is present in the site's top-level "package.json".
7:21:11 AM: In file "/opt/build/repo/app/.netlify/functions-internal/render.js"
7:21:11 AM: Cannot find module './llhttp/llhttp_simd.wasm.js' from '/opt/build/repo/app/.netlify'
7:21:11 AM:
7:21:11 AM: Resolved config
7:21:11 AM: build:
7:21:11 AM: base: /opt/build/repo/app
7:21:11 AM: command: npm run build
7:21:11 AM: commandOrigin: config
7:21:11 AM: publish: /opt/build/repo/app/build
7:21:11 AM: publishOrigin: config
7:21:11 AM: headers:
7:21:11 AM: - for: /_app/immutable/*
values:
cache-control: public, immutable, max-age=31536000
redirects:
- from: '*'
status: 200
to: /.netlify/functions/render
Caching artifacts
7:21:11 AM: Started saving node modules
7:21:11 AM: Finished saving node modules
7:21:11 AM: Started saving build plugins
7:21:11 AM: Finished saving build plugins
7:21:11 AM: Started saving pip cache
7:21:11 AM: Finished saving pip cache
7:21:11 AM: Started saving emacs cask dependencies
7:21:11 AM: Finished saving emacs cask dependencies
7:21:11 AM: Started saving maven dependencies
7:21:11 AM: Finished saving maven dependencies
7:21:11 AM: Started saving boot dependencies
7:21:11 AM: Finished saving boot dependencies
7:21:11 AM: Started saving rust rustup cache
7:21:11 AM: Finished saving rust rustup cache
7:21:11 AM: Started saving go dependencies
7:21:11 AM: Finished saving go dependencies
7:21:17 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:21:17 AM: Creating deploy upload records
7:21:17 AM: Failing build: Failed to build site
7:21:17 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
7:21:17 AM: Finished processing build request in 25.864000358s*
System Info
System:
OS: Linux 5.15 Ubuntu 20.04.2 LTS (Focal Fossa)
CPU: (8) x64 AMD EPYC 7B12
Memory: 18.46 GB / 62.80 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 16.13.2 - /nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/bin/node
npm: 8.1.2 - /nix/store/ra8r42571xvv1m85wanh1ll9mxmp0mwl-nodejs-16.13.2/bin/npm
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.53
@sveltejs/adapter-netlify: ^1.0.0-next.66 => 1.0.0-next.66
@sveltejs/kit: next => 1.0.0-next.357
svelte: ^3.44.0 => 3.48.0
Severity
blocking all usage of SvelteKit
Additional Information
I won’t be able to use sveltekit if this error is not fixed.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 23
- Comments: 33 (18 by maintainers)
I’ve just had the same thing happen to me, but fixed the issue by using @sveltejs/adapter-netlify directly (rather than via @sveltejs/adapter-auto) and pinning to the previous version of the adapter.
Let’s reopen this one. I don’t see an open issue on it and it is still currently broke on the
@next
version of adapter-netlify.This works for me.
The changed default runtime has now rolled out, so new deploys should be on 16 now unless manually specifying another version.
Same happens to me. I’ve posted on Netlify forum as well: https://answers.netlify.com/t/debugging-advice-when-trying-to-deploy-sveltekit-to-netlify-cannot-find-module-llhttp-llhttp-simd-wasm-js-from-opt-build-repo-netlify/70397
@sw-yx I think now that Netlify’s default is 16, you should be able to remove it completely.
@ascorbic That fixed it ty
The default node Lambda runtime on Netlify is currently 14 (though it’s changing to 16 on Monday), so you may need to manually set it. Set the env var
AWS_LAMBDA_JS_RUNTIME
tonodejs16.x
and do a new deployment.@brittneypostma Check your package-lock for references to
@sveltejs/adapter-netlify": "1.0.0-next.66"
. That was the fault in my case I had some lingering references to the latest version of the adapter.I can’t netlify build even in local.