首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误[ERR_REQUIRE_ESM] - Husky,lint-staged,eslint:

错误[ERR_REQUIRE_ESM] - Husky,lint-staged,eslint:
EN

Stack Overflow用户
提问于 2021-11-14 07:03:01
回答 1查看 939关注 0票数 4

虽然这方面还有其他问题,但大多数都没有得到答复,或者给出的答复对我不起作用。

显然,它给出的结果是在node_modules中看到的,下面是给定的错误:

代码语言:javascript
复制
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/kamoraes/Workspace/node_adc/node_modules/supports-color/index.js from /home/kamoraes/Workspace/node_adc/.git/hooks/commit-msg not supported.
Instead change the require of index.js in /home/kamoraes/Workspace/node_adc/.git/hooks/commit-msg to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/kamoraes/Workspace/node_adc/.git/hooks/commit-msg:8:23) {
  code: 'ERR_REQUIRE_ESM'
}


Node v16.13.0

问题是,该项目处于它的第一步,快速地在同一节点和纱线上的另一台机器上重新执行项目,版本,不要给出相同的错误。还让我的一个朋友试试。没有错误。

此外,这个项目是一个过程,相同的步骤,下面是我现在的全部代码:

https://github.com/kaiqueAMoraes/clean-node-api

这个给定错误的最后提交是chore: eslintignore 6250e5bdea05cc2eb413c8a57a97e4bbe4bd5bb9

我加了哈士奇,皮棉

代码语言:javascript
复制
yarn add -D husky lint-staged

然后添加它们各自的配置文件。

.huskyrc.json:

代码语言:javascript
复制
{
  "hooks": {
    "pre-commit": "lint-staged"
  }
}

.lintstagedrd.json:

代码语言:javascript
复制
{
  "*.ts": [
    "eslint 'src/**' --fix",
    "git add"
  ]
}

供参考: tsconfig:

代码语言:javascript
复制
{
  "compilerOptions": {
    "outDir" : "./dist",
    "module": "commonjs",
    "target": "es2019",
    "strictNullChecks": true,
    "esModuleInterop": true,
    "allowJs": true
  }
}

eslintrc:

代码语言:javascript
复制
{
  "extends": "standard-with-typescript",
  "parserOptions": {
    "project": "./tsconfig.json"
  }
}

gitignore和eslintignore都忽略node_modules和dist

EN

回答 1

Stack Overflow用户

发布于 2022-04-18 17:58:15

也遇到了同样的问题。你可以用git commit -m "your message here" --no-verify绕过支票。

票数 -3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69960974

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档