khrome / ascii-art

A Node.js library for ansi codes, figlet fonts, ascii art and other ASCII graphics
MIT License
681 stars 287 forks source link

[ERROR] No loader is configured for ".node" files: node_modules/canvas/build/Release/canvas.node #28

Open zxkane opened 2 years ago

zxkane commented 2 years ago

Using this library in a TypeScript app with esbuild, see the below error,

$ /home/ubuntu/environment/checker/node_modules/.bin/esbuild --bundle /home/ubuntu/environment/checker/src/lambda.d/checker/index.ts --target=node14 --platform=node --outfile=/home/ubuntu/environment/checker/cdk.out/bundling-temp-a5c74f113b8c87a1a34f41dde7ae72eba852d1bccfbaa6b6573360a5e136168d/index.js --external:aws-sdk
✘ [ERROR] No loader is configured for ".node" files: node_modules/canvas/build/Release/canvas.node

    node_modules/canvas/lib/bindings.js:3:25:
      3 │ module.exports = require('../build/Release/canvas.node')
        ╵                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1 error
child_process.js:830
    throw err;
    ^

Error: Command failed: /home/ubuntu/environment/checker/node_modules/esbuild-linux-64/bin/esbuild --bundle /home/ubuntu/environment/checker/src/lambda.d/checker/index.ts --target=node14 --platform=node --outfile=/home/ubuntu/environment/checker/cdk.out/bundling-temp-a5c74f113b8c87a1a34f41dde7ae72eba852d1bccfbaa6b6573360a5e136168d/index.js --external:aws-sdk
    at checkExecSyncError (child_process.js:790:11)
    at Object.execFileSync (child_process.js:827:15)
    at Object.<anonymous> (/home/ubuntu/environment/checker/node_modules/esbuild/bin/esbuild:109:26)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 4825,
  stdout: null,
  stderr: null
}
error Command failed with exit code 1.

Any hint to resolve it?

khrome commented 2 years ago

This is coming from canvas, which uses a native cairo binding.

I'll see if there's an update(one that may contain a resolution) before the next release, but I'm guessing it's related to this.

In the meantime, I would recommend excluding canvas from checking.

If this is a browser app, exclude canvas entirely as it will pick up the browser native one.

Additionally I'll leave this open until the underlying issue is solved and the dependency is upgraded.