node.script: Node script not ready can't handle message bang
Hello,
I have a very simple patch where i load a node.script and it is giving me this error:
node.script: Node script not ready can't handle message bang
my js file is in the same folder as my patch file
all syntax is correct, checked multiple times
test js is:
post("test.js loaded");function bang() { outlet(0, 12345);}and i've uploaded my maxpat file.
please help and thanks in advance
Node is a little different to regular js/v8, you need to import the max-api and reference it for each function call:
const max = require('max-api');
max.post("hello");
max.addHandler("bang", () => {
max.outlet(0, 12345);
});I've also added a [loadbang] -> [script start] -> [node.script test.js]
This ensures the script starts as soon as the patcher has loaded. You usually need to start the script before calling functions within it.

Patch above. File -> New From Clipboard. Be sure to re-attach the updated test.js. Hope this helps!
P.S: [node.script] has 1 outlet for messages, therefore you usually don't need to reference "0" as the first outlet argument. Instead, this acts as a list of args.