question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot build with .node files and Vercel adapter

See original GitHub issue

Describe 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

  1. Initialize new Sveltekit project
  2. Install sharp pnpm i sharp
  3. Create a new endpoint and import sharp
  4. Add Vercel adapter
  5. 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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:24 (13 by maintainers)

github_iconTop GitHub Comments

5reactions
haishanhcommented, Jun 29, 2021

Try add a postbuild inside scripts in package.json

In my case, I’m using Prisma with N-API I have:

  "postbuild": "cp node_modules/.prisma/client/*.node .vercel_build_output/functions/node/render/;cp prisma/schema.prisma .vercel_build_output/functions/node/render/;ls .vercel_build_output/functions/node/render/",

see also this comment I posted in Prisma repo.

5reactions
Nick-Mazukcommented, Jun 24, 2021

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vercel-adapter build error : r/sveltejs - Reddit
Hey guys, i currently came across this error when i'm trying to build and deploy my app to vercel. TypeError: utils.rimraf is not...
Read more >
0 - Stack Overflow
I'm trying to deploy a sveltekit app to vercel with adapter-vercel . It's just a basic SPA app. ... These are my settings...
Read more >
Adapters – Vercel Docs
These adaptors are plugins that take your app as input during build and ... we will swap our adapter-auto for adapter-node in our...
Read more >
@sveltejs/adapter-vercel - npm
@sveltejs/adapter-vercel. TypeScript icon, indicating that this package has built-in type declarations. 1.0.0 • Public • Published 14 days ...
Read more >
astrojs/vercel - Astro Documentation
This will install the adapter and make the appropriate changes to your astro.config.mjs file in one step. # Using NPM npx astro add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found