【发布时间】:2023-01-17 03:29:40
【问题描述】:
我收到这个错误
/home/runner/work/toDoList/toDoList/webpack.config.js
2:35 error Unable to resolve path to module 'html-webpack-plugin' import/no-unresolved
在由 GitHub 操作运行的我的 linters 上。
我在本地运行 eslint 时没有收到此错误;这只发生在 GitHub 操作中。这些解决方案对我不起作用。
- How to manually add a path to be resolved in eslintrc
- Using eslint with typescript - Unable to resolve path to module
- eslint / typescript: Unable to resolve path to module
- Why I got error Unable to resolve path to module? Eslint with Typescript
- https://www.appsloveworld.com/reactjs/200/340/sublime-eslint-plugin-unable-to-resolve-path-to-module-while-the-path-exist
这是我的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/"
]
}
如果我遗漏了什么,这是pull request with error。
【问题讨论】:
-
您应该在运行 eslint
npm install之前安装模块 -
你是对的。
html-webpack-plugin未安装在 GitHub 操作环境中。
标签: javascript webpack eslint bundler