在使用eslint配置时,提交出现bug:文章来源:https://www.toymoban.com/news/detail-585881.html
C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:729
return old(m, filename);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\USER\Desktop\tindin\node_modules\node-fetch\src\index.js from C:\Users\USER\Desktop\tindin\src\api\services\unsplash.ts not supported.
Instead change the require of index.js in C:\Users\USER\Desktop\tindin\src\api\services\unsplash.ts to a dynamic import() which is available in all CommonJS modules.
at Object.require.extensions.<computed> [as .js] (C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:729:20)
at Object.<anonymous> (C:\Users\USER\Desktop\tindin\src\api\services\unsplash.ts:23:30)
at Module.m._compile (C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:735:29)
at Object.require.extensions.<computed> [as .ts] (C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\index.js:737:16)
at main (C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:238:16)
at Object.<anonymous> (C:\Users\USER\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:351:5) {
code: 'ERR_REQUIRE_ESM'
}
本人参考了一些解决方案,但都未解决该问题,相关解决方式链接如下:
return old(m, filename); Error [ERR_REQUIRE_ESM]: require() of ES Module文章来源地址https://www.toymoban.com/news/detail-585881.html
我的解决方式: 将根目录下的 `commitlint.config.js`文件后缀名改为 cjs,即 commitlint.config.cjs 文件
到了这里,关于【解决ESlint的bug】return old(m, filename); Error [ERR_REQUIRE_ESM]: require() of ES Module的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!