I have the a file index.js
with these contents:
const test = function (cb) { cb(); };
test(myCallback = function () { console.log('done'); });
When I run index.js
using Node v16.6.1 and CommonJS:
done
When I run index.js
using Node v16.6.1 with "type": "module"
in my package.json
file:
ReferenceError: myCallback is not defined
Can you tell me whether and how this relates to ECMAScript modules?