Open hello-1tab opened 8 hours ago
Hi,
latest CI run was on Node v22.5.1 and went green. I also don't experience this error in any other project. What's your bundler setup?
This is very easy to reproduce with node v20.12.2 for example.
Make index.js
file with the following content.
import analytics from '@haensl/google-analytics/measurement-protocol.js';
console.log(analytics);
and start the script node index.js
I receive the same error.
I've seen the pipeline status before the submission of the issue. Not sure why the tests don't catch this issue correctly.
Anyway, switching to Node v22.5.1 gives slightly different error when i try running Node.JS on the code above:
TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "***/node_modules/@haensl/http/index.json" needs an import attribute of "type: json"
Probably jest injects custom loader for json files and that's why CI shows different behavior but i'm not sure about this.
Node.JS throws an error when i try to import
measurement-protocol.js
file in my code.TypeError [ERR_IMPORT_ASSERTION_TYPE_FAILED]: Module "***/node_modules/@haensl/google-analytics/measurement-protocol.js" is not of type "json"
For example, the import below will fail in Node.JS v17.5.0 and above.
import analytics from '@haensl/google-analytics/measurement-protocol.js';
This is because
measurement-protocol.js
contains following line and import attributes are required since v17.5.0:import http from '@haensl/http';
I think it should be fixed like this -
import http from '@haensl/http' with { type: 'json' };
to support newer Node.JS versions.