Hi averyone. Need help. I got the issue in Node-red
require() of ES modules is not supported.
require() of /home/ubuntu/scalar-crm-integration/externalModules/node_modules/node-fetch/src/index.js from /usr/lib/node_modules/node-red/node_modules/@node-red/registry/lib/externalModules.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/ubuntu/scalar-crm-integration/externalModules/node_modules/node-fetch/package.json.```
My node-red application hosted on AWS Linux server and managed by pm2. I try to export external modules to function node like moment or node-fetch and get thise issue. But I have not any troubles on my local machine
"Error: Function node failed to load external modules"
Check to see if you have the same version of node-fetch installed in both places. Perhaps you have an older version locally that can be required, rather than imported.
The fact remains, Node-RED wasn't updated to use import for external modules until 2.x.