ESM error in v4 consuming plugins in a Windows env
See original GitHub issueI’m seeing the following error after updating ember-template-lint
and ember-template-lint-plugin-prettier
to 4.0.0.
(node:1584) UnhandledPromiseRejectionWarning: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\cfries\Documents\Repositories\etlpp\node_modules\ember-template-lint-plugin-prettier\ember-template-lint-plugin-prettier.js
require() of ES modules is not supported.
require() of C:\Users\cfries\Documents\Repositories\etlpp\node_modules\ember-template-lint-plugin-prettier\ember-template-lint-plugin-prettier.js from C:\Users\cfries\Documents\Repositories\etlpp\node_modules\ember-template-lint\lib\get-config.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename ember-template-lint-plugin-prettier.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\cfries\Documents\Repositories\etlpp\node_modules\ember-template-lint-plugin-prettier\package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at requirePlugin (file:///C:/Users/cfries/Documents/Repositories/etlpp/node_modules/ember-template-lint/lib/get-config.js:38:12)
at async processPlugins (file:///C:/Users/cfries/Documents/Repositories/etlpp/node_modules/ember-template-lint/lib/get-config.js:150:16)
at async getProjectConfig (file:///C:/Users/cfries/Documents/Repositories/etlpp/node_modules/ember-template-lint/lib/get-config.js:396:22)
at async Linter.loadConfig (file:///C:/Users/cfries/Documents/Repositories/etlpp/node_modules/ember-template-lint/lib/linter.js:48:19)
at async Linter.verify (file:///C:/Users/cfries/Documents/Repositories/etlpp/node_modules/ember-template-lint/lib/linter.js:304:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1584) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:1584) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Reproduction: https://github.com/charlesfries/etlpp
"ember-cli": "~4.0.1",
"ember-source": "~4.0.1",
"ember-template-lint": "^4.0.0",
"ember-template-lint-plugin-prettier": "^4.0.0",
// .template-lintrc.js
'use strict';
module.exports = {
plugins: ['ember-template-lint-plugin-prettier'],
extends: ['recommended', 'ember-template-lint-plugin-prettier:recommended'],
};
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Enable consuming of ES modules in extensions · Issue #130367
When developing extensions and using either JavaScript or TypeScript we are unable to consume ES modules, only somewhat legacy CommonJS ...
Read more >Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The node-fetch latest version doesn't use the require() syntax to import the package. You need to go to your package.json and type
Read more >How to Create and Publish a React Component Library
The error is when our JSX code is encountered. If you recall we used Typescript to handle JSX with our rollup config, and...
Read more >babel/plugin-transform-runtime
If you need to polyfill them, you can directly import "core-js" or use @babel/preset-env 's useBuiltIns option. Installation. Install it as development ...
Read more >Micro Focus ESM Administrator's Guide
Micro Focus shall not be liable for technical or editorial errors or ... To set up ESM in a managed security service provider...
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
This issue was initially opened in ember-template-lint-plugin-prettier. I transfer it to ember-template-lint, where we will fix it. Thanks for the report @charlesfries.
I am giving this a second thought. Could you tell me what your node version is?