Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.17k stars 1.17k forks source link

Webpack node-loader - Error: libgif.so.7: No such file or directory / Error: /lib/x86_64-linux-gnu/libjpeg.so.62: version `LIBJPEGTURBO_6.2' not found #1723

Open tonytangio opened 3 years ago

tonytangio commented 3 years ago

Issue

Using Node v10.23.0 with TypeScript and Webpack.

Attempting to locally build and run my project with Webpack results in the error:

(node:8833) UnhandledPromiseRejectionWarning: Error: node-loader:
Error: /lib/x86_64-linux-gnu/libjpeg.so.62: version `LIBJPEGTURBO_6.2' not found (required by /home/mysterise/projects/mystbot/dist/1ac5511a17d7ad694cfe905612b1d208.node)

Attempting the same build, but in a node:10 base docker image results in a similar but slightly different error:

(node:72) UnhandledPromiseRejectionWarning: Error: node-loader:
Error: libgif.so.7: cannot open shared object file: No such file or directory

This is with the following relevant Webpack configuration for loading the Canvas dependencies:

module.exports = {
    ...,
    resolve: {
        modules: ['src', 'node_modules'],
        extensions: [ '.ts', '.js', '.json', '.node' ],
    },
    module: {
        rules: [
            {
                test: /\.ts$/,
                use: 'ts-loader',
                exclude: /node_modules/,
            },
            {
                test: /\.node$/,
                loader: 'node-loader'
            }
        ]
    }
};

Additional Information

Running the project source directly with ts-node (development) rather than building with Webpack (production) does not have this issue.

Canvas is installed normally without --build-from-source.

libjpeg62 is installed and up to date.

libjpeg62/focal,now 1:6b2-3 amd64

Your Environment

0xts commented 2 years ago

@tonytangio uninstall the libjpeg62 and install libjpeg62-turbo_2.0.6-4_amd64.deb. Also, it might ask you to recompile against correct NODE_MODULE_VERSION.