GitHub Actions执行ESLint时无法解析html-webpack-plugin模块
GitHub Actions运行ESLint报错:无法解析html-webpack-plugin模块
在GitHub Actions中运行代码检查工具时,出现以下错误:
/home/runner/work/toDoList/toDoList/webpack.config.js 2:35 error Unable to resolve path to module 'html-webpack-plugin' import/no-unresolved
本地运行ESLint时完全正常,仅在GitHub Actions环境下触发该问题。已尝试多个相关解决方案,但均未解决。
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/" ] }
内容的提问来源于stack exchange,提问作者shasherazi
相关产品推荐
相关产品推荐

