I'm running some webhooks on Netlify, but I'm getting an uncaught exception: Runtime.ImportModuleError.
Here is the full error, and you can access a snapshot of the function HERE
{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'safe-buffer'
Require stack:
- /var/task/src/node_modules/mqtt/lib/connect/ws.js
That is when I import 'async-mqtt', but the problem is that I have another function which uses the exact same import, without any problem. I can reproduce it on another function, but I'm not sure how I can go about reproducing it separately. I'm really lost, so ask if there is any information I need to explain.
Netlify runs on AWS functions, if that can help. Here is the full code of the function:
console.log('at least it opens');
const mqtt = require('async-mqtt');
exports.handler = async function (event, context) {
const client = await mqtt.connectAsync(
'mqtts://mqtt.flespi.io', {
username: 'SECRET HERE',
port: 8883,
clientId: `action-on-google--${Math.random().toString(16).substr(2, 8)}`,
},
);
await client.publish('lights/bulbs', 'N255,0');
client.end();
return { statusCode: 200, body: 'Hello world' };
};
question from:
https://stackoverflow.com/questions/65910129/netlify-functions-uncaught-exception-runtime-importmoduleerror 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…