You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there is way for Husky to work with the new native ESM support of Node.js ? I'm working on a Node.js monitoring agent where we use Node ESM but husky stop working because of the type: "module" in the package.json (i guess).
$ git commit -m "fix: remove nsecure-result"
husky > commit-msg (node v14.2.0)
F:\Code\SlimIO\Core\node_modules\@commitlint\cli\lib\cli.js:124
throw err;
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: F:\Code\SlimIO\Core\commitlint.config.js
require() of ES modules is not supported.
require() of F:\Code\SlimIO\Core\commitlint.config.js from F:\Code\SlimIO\Core\node_modules\cosmiconfig\node_modules\import-fresh\index.js is an ES module file as it is a .js file whose nearest parent package.jso
n contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename commitlint.config.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from F:\Code\SlimIO\Core\package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1192:13)
at Module.load (internal/modules/cjs/loader.js:1040:32)
at Function.Module._load (internal/modules/cjs/loader.js:929:14)
at Module.require (internal/modules/cjs/loader.js:1080:19)
at require (internal/modules/cjs/helpers.js:72:18)
at module.exports (F:\Code\SlimIO\Core\node_modules\cosmiconfig\node_modules\import-fresh\index.js:28:9)
at loadJs (F:\Code\SlimIO\Core\node_modules\cosmiconfig\dist\loaders.js:9:18)
at Explorer.loadFileContent (F:\Code\SlimIO\Core\node_modules\cosmiconfig\dist\createExplorer.js:230:12)
at F:\Code\SlimIO\Core\node_modules\cosmiconfig\dist\createExplorer.js:252:21 {
code: 'ERR_REQUIRE_ESM'
}
husky > commit-msg hook failed (add --no-verify to bypass)
Same issue here. Using node 12 and husky in a type: module package and when running npm install I get this error:
Must use import to load ES Module: C:\Users\username\Projects\project\husky.config.js
require() of ES modules is not supported.
require() of C:\Users\username\Projects\project\husky.config.js from C:\Users\username\Projects\project\node_modules\cosmiconfig\dist\loaders.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 husky.config.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\username\Projects\project\package.json.
husky > Failed to install
Not sure if this is a cosmiconfig issue in the first place?! There's an open issue regarding mjs and cjs files as well.
Hi,
Is there is way for Husky to work with the new native ESM support of Node.js ? I'm working on a Node.js monitoring agent where we use Node ESM but husky stop working because of the type: "module" in the package.json (i guess).
Doc for Node.js ESM: https://nodejs.org/api/esm.html
I tried a lot of things but nothing work so far.
Repo example: https://github.com/SlimIO/core
Best Regards,
Thomas
The text was updated successfully, but these errors were encountered: