gio
11/26/2021, 8:51 AMnpx sst start
I get this error:
==========================
Starting Live Lambda Dev
==========================
Transpiling Lambda code...
> addons/foo/node_modules/jsdom/lib/jsdom/utils.js:160:25: error: Could not resolve "canvas" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
160 │ const Canvas = require("canvas");
I’ve been marked canvas
as external, in this way:
const topic = new sst.Topic(stack, 'mail-receipt', {
subscribers: ['addons/foo/index.foo'],
snsTopic: {
topicName: 'mail-receipt'
},
defaultFunctionProps: {
bundle: {
externalModules: ['canvas']
}
}
});
After this change I don’t get any error when I run sst deploy
but I still have the same problem “Could not resolve “canvas”… ” when run sst start
Is there any difference on esbuild process between deploy/start?
Any suggestion to solve it?Ross Coundon
11/26/2021, 9:04 AMgio
11/26/2021, 9:27 AMcanvas
is required; version 1.x is no longer supported.
I tried to install many times canvas but I get this error:
==========================
Starting Live Lambda Dev
==========================
Transpiling Lambda code...
> addons/foo/node_modules/canvas/lib/bindings.js:3:25: error: No loader is configured for ".node" files: addons/turo-sync/node_modules/canvas/build/Release/canvas.node
3 │ module.exports = require('../build/Release/canvas.node');
Should I load canvas.node thorough bundle settings?
I’m using monorepo with yarn.Frank
No loader is configured
error, try configuring the loader inside bundle like this https://docs.serverless-stack.com/constructs/Function#configure-bundlingFrank
Could not resolve "canvas"
error, do you have canvas
npm installed inside ur nodeModules?gio
11/26/2021, 1:40 PMconst topic = new sst.Topic(stack, 'mail-receipt', {
subscribers: ['addons/foo/src/index.emailReceiptTrigger'],
snsTopic: {
topicName: 'mail-receipt'
},
defaultFunctionProps: {
bundle: {
externalModules: ['canvas'],
loader: {
".node": "dataurl",
},
}
}
});
canvas wasn’t installed because I just update jsdom (after v13 canvas was required)Frank
canvas
installed, that would’ve resolved the original error.