Closed RSS1102 closed 1 year ago
没看明白你的意思。看日志意思是说 "type": "module"
会把所有 .js
都作为 es module 解析,所以不能在其中使用 require
语法。
没看明白你的意思。看日志意思是说
"type": "module"
会把所有.js
都作为 es module 解析,所以不能在其中使用require
语法。
是的,我看到这个日志也是这样认为的(eslint日志推荐我使用.cjs结尾的文件)。所以我不知道为啥会出现这个错误提示(即使我去掉了package.json内的"type": "module"
),您没有遇到这种情况嘛。
参考这个吧 https://stackoverflow.com/questions/70487806/must-use-import-to-load-es-module-eslintrc-js
ok,谢谢你的解答,我似乎明白了一些。不管怎样,我正确运行了它,并且得到我期望的效果。
看到eslint官网的一段话,补充一下: JavaScript (ESM) - use .eslintrc.cjs when running ESLint in JavaScript packages that specify "type":"module" in their package.json. Note that ESLint does not support ESM configuration at this time.
再次感谢您的耐心解答。
.eslintrc.js`:
use
.eslintrc.cjs
,I succeeded in getting the correct eslint warning. Then I changed it to.eslintrc.js
again and still got the correct elslint warning.I don't understand why. Or i changed
"type": "module"
in package.json. Why do I change it? Will it affect me?