0

I am getting this error

/home/runner/work/toDoList/toDoList/webpack.config.js
  2:35  error  Unable to resolve path to module 'html-webpack-plugin'  import/no-unresolved

on my linters run by GitHub actions.

I do not get this error when I run eslint locally; this only happens in GitHub actions. These solutions did not work for me.

Here is my 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'],
      },
    ],
  },
};

And my .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/"
  ]
}

Here is the pull request with error if I'm missing something.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
shasherazi
  • 100
  • 10

3 Answers3

1

Turns out my html-webpack-plugin wasn't getting installed in the GitHub actions environment because it wasn't in linters.yml file. Adding npm install html-webpack-plugin in linters.yml solved the issue.

shasherazi
  • 100
  • 10
0

@shasherazi is right, in my case I added it like below under eslint run: | npm install html-webpack-plugin just before the eslint install command in linters.yml file

Newton
  • 31
  • 4
0

"npm install html-webpack-plugin" is added to the linter file as in the picture

"npm install html-webpack-plugin" is added to the linter file as in the picture

Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • 4
    Welcome to Stack Overflow! Please [edit] your post to add code and data as text ([using code formatting](https://stackoverflow.com/editing-help#code)), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and [many more reasons](https://meta.stackoverflow.com/a/285557). Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data. See [mcve] on what code is required. – Adriaan Feb 24 '23 at 06:18