ERR_IMPORT_ASSERTION_TYPE_MISSING for Node >=16.14.0
See original GitHub issueThe 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:
- Created a year ago
- Comments:9
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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. 🚀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.