解決方法
局部配置:
在需要使用CommonJS的文件頭部使用:
/* eslint-env node */
全局配置:
在.eslintrc.cjs 文件里添加node環(huán)境變量
module.exports = {
env: {
node: true
},
}
不太推薦:
module.exports 改為 export default文章來源:http://www.zghlxwxcb.cn/news/detail-757211.html
分析原因
ESLint檢查嚴(yán)格,默認(rèn)不支持CommonJS語法,不過可以看到.eslintrc.cjs 文件就使用了/* eslint-env node */ 和 module.exports,真是讓人饒頭。文章來源地址http://www.zghlxwxcb.cn/news/detail-757211.html
到了這里,關(guān)于解決ESLint 報 ‘module‘ is not defined的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!