You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in C:\user\Node-red\node_modules\@jsonquerylang\jsonquery\package.json #27
Hello,
I'm trying to use @jsonquerylang/jsonquery version 5.0.4 in a Node-RED environment, which relies on CommonJS modules and synchronous require() calls in its settings.js configuration file.
Unfortunately, the current version of the package does not define an "exports" field in its package.json, and it appears to be bundled as a pure ESM module. This causes the following error when attempting to use it via require():
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in node_modules/@jsonquerylang/jsonquery/package.json
This makes it impossible to use the package in environments like Node-RED that do not support import() or asynchronous module loading in configuration files.
What we need:
A defined "exports" field in package.json that allows access to the main entry point (e.g. jsonquery, compile, etc.) via CommonJS require().
Alternatively, a dual-module build (ESM + CommonJS) or a separate CommonJS-compatible wrapper.
Why this matters:
Node-RED is widely used in industrial and automation environments, and many users rely on synchronous module loading via require() in settings.js. Without CommonJS compatibility, it's currently impossible to use jsonquery in global context or in standard function nodes without resorting to async hacks or custom node development.
Would it be possible to add CommonJS support or at least expose the main entry point via "exports"?
Thank you for your great work on this library — it’s extremely useful and powerful, and we’d love to be able to use it in more environments.
I was trying to install new version of node. Now I am using latest LTS: 24.11.1 but basically I have the same problem.
When I do const JSONQuery = require('@jsonquerylang/jsonquery');
I get "[object Promise]" instead of a function. This breaks existing code because the module is ESM-only and require() returns a Promise.
If I try to use import I get: Error: Module not allowed
seems like Node-RED sandbox does not allow dynamic imports.
I'm not familiar with Node-RED so I'm not sure what they do and don't support. Since all of the JavaScript ecosystem is moving towards ESM it sounds important to me that Node-RED supports ESM too. Maybe you should ask about this at Node-RED itself?
Hello, Thank you for your support.
Actually it does not help because is pretty old - this we was using till now but for new versions of NR it does not work anymore.
But I also left there a question so I believe they will able to provide some solution.
Activity
josdejong commentedon Nov 11, 2025
The library is indeed just ESM.
What version of Node.js are you using? Since Node.js v22 you can load ESM modules via
requiretoo (see article).strbaknxp commentedon Nov 11, 2025
Oh oki,
thanks a lot, I am using old v20. I will try to update. Thank you :)
strbaknxp commentedon Nov 13, 2025
Hello,
I was trying to install new version of node. Now I am using latest LTS: 24.11.1 but basically I have the same problem.
When I do
const JSONQuery = require('@jsonquerylang/jsonquery');I get "[object Promise]" instead of a function. This breaks existing code because the module is ESM-only and require() returns a Promise.
If I try to use import I get: Error: Module not allowed
seems like Node-RED sandbox does not allow dynamic imports.
josdejong commentedon Nov 13, 2025
I just tested in a CommonJS file and you can indeed load the ESM library in Nodejs 22 and newer via:
I'm not familiar with Node-RED so I'm not sure what they do and don't support. Since all of the JavaScript ecosystem is moving towards ESM it sounds important to me that Node-RED supports ESM too. Maybe you should ask about this at Node-RED itself?
josdejong commentedon Nov 13, 2025
The following issue suggests that ESM can be loaded (after the issue was fixed): node-red/node-red#3627 . Does that help?
strbaknxp commentedon Nov 14, 2025
Hello, Thank you for your support.
Actually it does not help because is pretty old - this we was using till now but for new versions of NR it does not work anymore.
But I also left there a question so I believe they will able to provide some solution.
Thanks a lot :)
josdejong commentedon Nov 14, 2025
👍