错误 无法解析模块路径 'html-webpack-plugin' import/no-unresolved

18 浏览
0 Comments

错误 无法解析模块路径 '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中。这些解决方案对我没有起作用:

这是我的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/"

]

}

如果我漏掉了什么,请查看带有错误的拉取请求

0
0 Comments

问题原因:无法解析模块'html-webpack-plugin'的路径。

解决方法:执行以下命令安装'html-webpack-plugin'模块。

npm install html-webpack-plugin

0
0 Comments

在上述内容中,出现了一个问题(error Unable to resolve path to module 'html-webpack-plugin' import/no-unresolved)。这个问题的出现原因是无法解析到模块'html-webpack-plugin'的路径。解决这个问题的方法是在'linters.yml'文件中,在eslint安装命令之前添加以下内容:

run: | npm install html-webpack-plugin

0
0 Comments

错误原因:在GitHub actions环境中,html-webpack-plugin未被安装,因为它未在linters.yml文件中。将npm install html-webpack-plugin添加到linters.yml解决了这个问题。

解决方法:在linters.yml文件中添加npm install html-webpack-plugin

0