question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERR_IMPORT_ASSERTION_TYPE_MISSING for Node >=16.14.0

See original GitHub issue

The generated content collection file - allxxxx file, cannot be imported and used directly in a node script for node >= 16.14.0 as importing JSON modules now requires experimental import assertions syntax.

Not sure what’s the best workaround as adding the assert { type: 'json' } syntax is invalid for Node 14. Alternatively, one could consider generating js files rather than json?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
schicklingcommented, Mar 29, 2022

That’s a really great suggestion @seancdavis. I’ve just implemented this behaviour (i.e. conditionally adding the assert { type: 'json' } if Node 16.14+ is used). For now I won’t make this behaviour user-configurable yet but wait until someone is actually facing a problem related to this or has another valid use case for making this configurable.

@timlrx this will be release with the upcoming 0.2.0 release. 🚀

2reactions
seancdaviscommented, Mar 28, 2022

I think this is a reasonable approach — opt-out vs opt-in.

There’s another option here for the “sensible” default to be contextualized based on the current version of Node running the CL build. If it’s pre-16.14, don’t write the assertions, otherwise, do it. And the configuration option could override this variable behavior to explicitly add or not add the assertion regardless of the node version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERR_IMPORT_ASSERTION_TY...
Import assertions address a security concern (v8.dev/features/import-assertions) about trusting cross-origin imports. – pbatey. Mar 21 at 23:07.
Read more >
Missing support for Node >=16.14.0 · Issue #9149 - GitHub
npm run build throws TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///Users/budnix/Documents/Projects/handsontable-develop/ ...
Read more >
TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING] in ...
Use an import assertion to solve the error "TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module needs an import assertion of type json", e.g. import myJson ...
Read more >
Import JSON in ES modules - Simon Plenderleith
If you want to try JSON imports with the import assertion syntax in Node. js v16 you'll need to be running >= v16....
Read more >
Node v16.14.0 (LTS)
This release adds experimental support for the import assertions stage 3 proposal. To keep Node.js ESM implementation as compatible as possible ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found