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

No loader is configured for ".node" files? #198

Open
alexo382 opened this issue Feb 5, 2023 · 14 comments
Open

No loader is configured for ".node" files? #198

alexo382 opened this issue Feb 5, 2023 · 14 comments

Comments

@alexo382
Copy link

alexo382 commented Feb 5, 2023

I'm trying to use resvg-js in a Remix project with a Node runtime but I don't seem to be able to get around this error:

No loader is configured for ".node" files: node_modules/@resvg/resvg-js-darwin-arm64/resvgjs.darwin-arm64.node

Any tips to get past this would be greatly appreciated. I'm running macOS Ventura with an M1 CPU.

Thanks!

@yisibl
Copy link
Owner

yisibl commented Feb 5, 2023

Can you find this .node file in your node_modules directory?
It would be nice to provide a minimized example project to replicate this.

@alexo382
Copy link
Author

alexo382 commented Feb 5, 2023

Can you find this .node file in your node_modules directory? It would be nice to provide a minimized example project to replicate this.

I created a sample repo here: https://codesandbox.io/p/github/alexo382/test-resvg
The error output when running the dev server is misleading because when you try to build the app it fails because of the error I posted above.
Screenshot 2023-02-05 at 12 12 51

Is it because the Remix compiler that uses esbuild doesn't support .node files? It's strange because I spoke with a Remix user in discord that had resvg-js working fine in their projects.

Thanks again 🙏

@yisibl
Copy link
Owner

yisibl commented Feb 6, 2023

Please see: #175 (comment)

@unculture
Copy link

Perhaps you need to mark @resvg/resvg-js as external for esuild? I was getting this issue with Netlify (which uses esbuild) until I marked it as external in the Netlify config.

@Mxs2019
Copy link

Mxs2019 commented May 17, 2023

Has anyone figured this out?

@tresabhi
Copy link

tresabhi commented Jun 9, 2023

This is your solution; works 10 / 10 🥳

esbuild <input> --outfile=<output> --loader:.node=copy

@Mxs2019

@julianprester
Copy link

I have the same issue in a NextJS project. Could there be a webpack configuration that works? I found the node-loader?

I've also tried the proposed esbuild solution but couldn't get it to work.

@yisibl
Copy link
Owner

yisibl commented Aug 7, 2023

Here's a reference case used in netlify: creatures-sh/creatures.sh#2

@crisu83
Copy link

crisu83 commented Sep 28, 2023

I have the same issue in a NextJS project. Could there be a webpack configuration that works? I found the node-loader?

I've also tried the proposed esbuild solution but couldn't get it to work.

@julianprester Hey Julian, I faced the same issue in a Next.js project (version 13.5.3) and I was able to solve it by adding the library (in my case @resvg/resvg-js) to serverComponentsExternalPackages under experimental in my config file:

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    serverComponentsExternalPackages: ["@resvg/resvg-js"],
  },
  ...

I hope this helps.

Reference: https://nextjs.org/docs/app/api-reference/next-config-js/serverComponentsExternalPackages

@btakita
Copy link

btakita commented Oct 14, 2023

Same issue using bun & astrojs.

@jacobpretorius
Copy link

If you're using Astro you can add this to your astro.config.mjs

vite: {
    optimizeDeps: {
      exclude: ['@resvg/resvg-js'],
    },
  }

@Kayoshi-dev
Copy link

Hi!

I have the same issue with SvelteKit when I try to deploy on Vercel!

I added the following lines in my vite.config.js, without success :

	build: {
		rollupOptions: {
			external: ['@resvg/resvg-js']
		}
	},
	optimizeDeps: {
		exclude: ['@resvg/resvg-js']
	}

Does anyone have an example or an idea on how to fix the problem?

@Kayoshi-dev
Copy link

Note that I also tried with this config in svelte.config.js :

const config = {
preprocess: vitePreprocess(),

kit: {
	adapter: adapter({
		external: ['@resvg/resvg-js']
	})
}

};

Without success :/

@antmelnyk
Copy link
Contributor

antmelnyk commented Jun 10, 2024

This is still an issue. With latest Webpack or Vite, attempting to use:

import { Resvg } from "@resvg/resvg-js";

Is not working because underneath it imports .node files for each target platform for some reason. Excluding from optimizeDeps makes sense but it's still confusing what is the correct usage. I remember year ago my code was working like that.

Anyhow, for now I managed it to work on front-end with WASM using:

import { initWasm, Resvg } from "@resvg/resvg-wasm";

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