错误 无法解析模块路径 'html-webpack-plugin' import/no-unresolved
错误 无法解析模块路径 'html-webpack-plugin' import/no-unresolved
我在GitHub actions运行我的linters时遇到以下错误:
/home/runner/work/toDoList/toDoList/webpack.config.js 2:35 error 无法解析模块路径 'html-webpack-plugin' import/no-unresolved
但在本地运行eslint时,我没有遇到这个错误;这只发生在GitHub actions中。这些解决方案对我没有起作用:
- 如何在eslintrc中手动添加要解析的路径
- 使用eslint和typescript - 无法解析模块路径
- eslint / typescript:无法解析模块路径
- 为什么我会遇到错误Unable to resolve path to module?Eslint与Typescript
- Sublime eslint插件:“路径存在时无法解析模块路径”
这是我的webpack.config.js
文件:
const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { entry: './src/index.js', devtool: 'inline-source-map', devServer: { static: './dist', }, plugins: [ new HtmlWebpackPlugin({ template: './src/index.html', }), ], output: { filename: 'main.js', path: path.resolve(__dirname, 'dist'), }, module: { rules: [ { test: /\.css$/i, use: ['style-loader', 'css-loader'], }, ], }, };
还有我的.eslintrc.json
文件:
{
"env": {
"browser": true,
"es6": true,
"jest": true
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"extends": ["airbnb-base"],
"rules": {
"no-shadow": "off",
"no-param-reassign": "off",
"eol-last": "off",
"import/extensions": [ 1, {
"js": "always", "json": "always"
}]
},
"ignorePatterns": [
"dist/",
"build/"
]
}
如果我漏掉了什么,请查看带有错误的拉取请求。