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
When importing either a subset of libraries or the tree-shakeable library for any validator using ES6 modules, a NodeJS ES6 error is shown indicating that the module cannot be found
This has been reported here: #1759 (comment) but using either option (lib or es/lib) shows the same error.
The only path going forwards seems to be importing the entire library and using the function from there which creates a bundle file with unnecessary information
EDIT:
To isolate the issue, ran the same setup on a brand new Google Cloud VM using the same NodeJS and validator version. Ran into the same issue for both es/lib and /lib imports but it works importing the entire library
The issue is that this library isn't really ESM compliant because package.json does not have the exports field which would export all of these modules and thus standard ES module import won't work without a bundler that would try to fix that.
So until that is fixed, only was to import via ESM is to use the default export.
@pajasevi This information should be added to the readme, as it's not documented that it doesn't work without a bundler. The examples just state "ES6," but only one of the three examples given works without a bundler, and this caveat is not mentioned elsewhere.
Issue:
When importing either a subset of libraries or the tree-shakeable library for any validator using ES6 modules, a NodeJS ES6 error is shown indicating that the module cannot be found
Examples
This is the package.json file:
And the file calling the library (index.js):
This has been reported here: #1759 (comment) but using either option (lib or es/lib) shows the same error.
The only path going forwards seems to be importing the entire library and using the function from there which creates a bundle file with unnecessary information
EDIT:
To isolate the issue, ran the same setup on a brand new Google Cloud VM using the same NodeJS and validator version. Ran into the same issue for both es/lib and /lib imports but it works importing the entire library
Additional context
Validator.js version: 13.11.0
Node.js version: 20.10.0
OS platform: macOs
The text was updated successfully, but these errors were encountered: