Home > Software engineering >  error Unable to resolve path to module 'html-webpack-plugin' import/no-unresolved
error Unable to resolve path to module 'html-webpack-plugin' import/no-unresolved

Time:01-20

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.

CodePudding user response:

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.

  • Related