You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 07:05:19