Open front-zero opened 8 months ago
You have to use https://www.npmjs.com/package/nextjs-node-loader/v/1.1.1
@mathiasprisfeldt do you have an example how you use it ?
@udatny try this
npm install nextjs-node-loader --save-dev
// next.config.mjs
export default () => {
const nextConfig = {
webpack: (config) => {
config.module.rules.push(
{
test: /\.node$/,
use: [
{
loader: 'nextjs-node-loader',
},
],
},
);
return config;
}
};
return nextConfig;
};
you need to add @resvg/resvg-js
in serverComponentsExternalPackages
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ["@resvg/resvg-js"],
},
};
EDIT:
As of Next 15
, see https://nextjs.org/docs/app/api-reference/next-config-js/serverExternalPackages
const nextConfig = {
serverExternalPackages: ["@resvg/resvg-js"],
};
@joshxfi Your hint helped me solve a tricky issue. https://github.com/eisberg-labs/nextjs-node-loader/issues/45
hi!
I wrote logic to convert svg to png using resvg in next.js, but the following error occurred. Could I possibly get some help?
⨯ ./node_modules/@resvg/resvg-js-win32-x64-msvc/resvgjs.win32-x64-msvc.node Module parse failed: Unexpected character '�' (1:2) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file)
Import trace for requested module: ./node_modules/@resvg/resvg-js-win32-x64-msvc/resvgjs.win32-x64-msvc.node ./node_modules/@resvg/resvg-js/js-binding.js ./node_modules/@resvg/resvg-js/index.js ./src/utils/svgToPngUtil.ts ./src/app/api/satori/route.tsx ○ Compiling /not-found ... ⨯ ./node_modules/@resvg/resvg-js-win32-x64-msvc/resvgjs.win32-x64-msvc.node Module parse failed: Unexpected character '�' (1:2) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file)