ESM package is invalid
See original GitHub issuePackage.json mentions that this is an Node ES module:
But ESM requires file extensions, which are missing:
Additionally, your .
import actually point to the non-ESM version, so it’s doubly-incorrect:
import "css-selector-generator"'
fails becausebuild/index.js
not ESM at allimport "css-selector-generator/esm"
fails because it’s not a valid node ESM import
Little big note: To have file extensions you’ll have to write .js
in your TS imports, even if the file is actually .ts
; That’s TypeScript for you.
You might want to at-least-temporarily use this workflow to ensure that your module is importable from the tools you want to support:
https://github.com/fregante/ghatemplates/blob/main/esm-lint/esm-lint.yml
For reference, this is the error Webpack shows when importing /esm
directly:
ERROR in ./node_modules/css-selector-generator/esm/index.js 5:0-49
Module not found: Error: Can't resolve './constants' in './node_modules/css-selector-generator/esm'
Did you mean 'constants.js'?
BREAKING CHANGE: The request './constants' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
esm causes optional chaining to be viewed as invalid ...
Use of esm causes optional chaining to be viewed as invalid syntax. Here's an example: import get from 'lodash/fp/get'; const a = {...
Read more >node.js - How would you fix an 'ERR_REQUIRE_ESM' error?
1)Use fix esm https://www.npmjs.com/package/fix-esm module & import the module like this: const someModule = require("fix-esm"). · 2)Use dynamic ...
Read more >esm
Getting started. There are two ways to enable esm . Enable esm for packages: Use esm to load the main ES module and...
Read more >Solved: ESM Firmware Invalid Package Signature
ESM Firmware Invalid Package Signature. I am using OpenManage Essentials to update a newly installed "non-compliant" PowerEdge R510 server.
Read more >ECMAScript modules | Node.js v19.3.0 Documentation
Throw an Invalid Package Configuration error. Return the parsed JSON source of the file at pjsonURL. Customizing ESM specifier resolution algorithm#. The ...
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
All the issues seems to have been fixed in the package 🎉 I’ll let you know on the next update cycle 👍