Cannot build with .node files and Vercel adapter
See original GitHub issueDescribe the bug
Cannot build Sveltekit while using Sharp and the Vercel adapter. Sharp works in development. I suspect this issue applies to all dependencies with .node
files.
This seems unrelated to the “error when including packages” question in the FAQ or https://github.com/sveltejs/kit/issues/737
Logs
> Using @sveltejs/adapter-vercel
> node_modules/.pnpm/sharp@0.28.2/node_modules/sharp/lib/output.js:4:22: error: No loader is configured for ".node" files: node_modules/.pnpm/sharp@0.28.2/node_modules/sharp/build/Release/sharp.node
4 │ const sharp = require('../build/Release/sharp.node');
To Reproduce
- Initialize new Sveltekit project
- Install sharp
pnpm i sharp
- Create a new endpoint and import sharp
- Add Vercel adapter
pnpm build
Reproduction repo: https://github.com/Nick-Mazuk/sveltekit-sharp
Expected behavior
Site would build without issues.
Stacktraces
If you have a stack trace to include, we recommend putting inside a <details>
block for the sake of the thread’s readability:
Stack trace
pnpm build
> ~TODO~@0.0.1 build /Users/nickmazuk/Documents/Github/sveltekit-sharp
> svelte-kit build
vite v2.3.3 building for production...
✓ 14 modules transformed.
.svelte-kit/output/client/_app/manifest.json 1.21kb
.svelte-kit/output/client/_app/layout.svelte-39a4acb4.js 0.49kb / brotli: 0.29kb
.svelte-kit/output/client/_app/pages/index.svelte-af73b2f3.js 0.79kb / brotli: 0.42kb
.svelte-kit/output/client/_app/error.svelte-8eafbf20.js 1.19kb / brotli: 0.57kb
.svelte-kit/output/client/_app/assets/start-a8cd1609.css 0.16kb / brotli: 0.10kb
.svelte-kit/output/client/_app/chunks/vendor-3681a316.js 5.05kb / brotli: 1.98kb
.svelte-kit/output/client/_app/start-22b096ce.js 17.18kb / brotli: 5.50kb
vite v2.3.3 building SSR bundle for production...
transforming (1) .svelte-kit/build/app.js"default" is imported from external module "sharp" but never used in "src/routes/endpoint.js".
✓ 10 modules transformed.
.svelte-kit/output/server/app.js 9.40kb
Run npm run preview to preview your production build locally.
> Using @sveltejs/adapter-vercel
> node_modules/.pnpm/sharp@0.28.3/node_modules/sharp/lib/utility.js:7:22: error: No loader is configured for ".node" files: node_modules/.pnpm/sharp@0.28.3/node_modules/sharp/build/Release/sharp.node
7 │ const sharp = require('../build/Release/sharp.node');
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Build failed with 1 error:
node_modules/.pnpm/sharp@0.28.3/node_modules/sharp/lib/utility.js:7:22: error: No loader is configured for ".node" files: node_modules/.pnpm/sharp@0.28.3/node_modules/sharp/build/Release/sharp.node
Error: Build failed with 1 error:
node_modules/.pnpm/sharp@0.28.3/node_modules/sharp/lib/utility.js:7:22: error: No loader is configured for ".node" files: node_modules/.pnpm/sharp@0.28.3/node_modules/sharp/build/Release/sharp.node
at failureErrorWithLog (/Users/nickmazuk/Documents/Github/sveltekit-sharp/node_modules/.pnpm/esbuild@0.11.23/node_modules/esbuild/lib/main.js:1443:15)
at /Users/nickmazuk/Documents/Github/sveltekit-sharp/node_modules/.pnpm/esbuild@0.11.23/node_modules/esbuild/lib/main.js:1125:28
at runOnEndCallbacks (/Users/nickmazuk/Documents/Github/sveltekit-sharp/node_modules/.pnpm/esbuild@0.11.23/node_modules/esbuild/lib/main.js:1043:65)
at buildResponseToResult (/Users/nickmazuk/Documents/Github/sveltekit-sharp/node_modules/.pnpm/esbuild@0.11.23/node_modules/esbuild/lib/main.js:1123:7)
at /Users/nickmazuk/Documents/Github/sveltekit-sharp/node_modules/.pnpm/esbuild@0.11.23/node_modules/esbuild/lib/main.js:1230:14
at /Users/nickmazuk/Documents/Github/sveltekit-sharp/node_modules/.pnpm/esbuild@0.11.23/node_modules/esbuild/lib/main.js:606:9
at handleIncomingPacket (/Users/nickmazuk/Documents/Github/sveltekit-sharp/node_modules/.pnpm/esbuild@0.11.23/node_modules/esbuild/lib/main.js:703:9)
at Socket.readFromStdout (/Users/nickmazuk/Documents/Github/sveltekit-sharp/node_modules/.pnpm/esbuild@0.11.23/node_modules/esbuild/lib/main.js:573:7)
at Socket.emit (node:events:365:28)
at addChunk (node:internal/streams/readable:314:12)
ERROR Command failed with exit code 1.
Information about your SvelteKit Installation:
Diagnostics
System: OS: macOS 11.3 CPU: (16) x64 Intel® Core™ i9-9880H CPU @ 2.30GHz Memory: 8.95 GB / 64.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 16.1.0 - ~/.nvm/versions/node/v16.1.0/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.11.2 - ~/.nvm/versions/node/v16.1.0/bin/npm Browsers: Brave Browser: 90.1.24.86 Firefox: 87.0 Safari: 14.1 npmPackages: @sveltejs/kit: next => 1.0.0-next.109 svelte: ^3.34.0 => 3.38.2
- Adapter:
"@sveltejs/adapter-vercel": "^1.0.0-next.19"
- Sharp:
"sharp": "^0.28.3"
Severity
Blocking deployment of new feature.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:24 (13 by maintainers)
Top GitHub Comments
Try add a
postbuild
insidescripts
in package.jsonIn my case, I’m using Prisma with N-API I have:
see also this comment I posted in Prisma repo.
@alteredorange, I couldn’t figure out a workaround so I ended up creating a custom serverless function on Vercel. It’s very much not ideal, though.