gpt4 book ai didi

javascript - 无法在 webpack 中使用 eslint 加载器

转载 作者:行者123 更新时间:2023-12-03 04:42:08 25 4
gpt4 key购买 nike

我对 webpack 越来越熟悉了。在我尝试将 eslint loader 添加到我的 webpack 配置中之前,一切进展顺利。我得到了

ERROR in ./src/index.js Module build failed: Error: Cannot find module 'eslint'

在我的控制台中运行 webpack 命令时。这是我的 webpack.config.js

let path = require('path');

module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname + '/dist'),
filename: 'bundle.js',
},
module: {
rules: [{
test: /\.js$/,
use: [
'eslint-loader', {
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}],
exclude: /node_modules/,
}, {
test: /\.scss$/,
use: [{
loader: 'style-loader' // creates style nodes from JS strings
}, {
loader: 'css-loader' // translates CSS into CommonJS
}, {
loader: 'sass-loader' // compiles Sass to CSS
}],
exclude: /node_modules/
}]
}
}

我的package.json:

{
"name": "animatio",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server",
"deploy": "git push evennode master"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
"babel-preset-es2015": "^6.24.0",
"css-loader": "^0.27.3",
"eslint-loader": "^1.7.0",
"express": "^4.15.2",
"sass-loader": "^6.0.3",
"style-loader": "^0.16.0",
"webpack": "^2.3.2"
},
"dependencies": {
"node-sass": "^4.5.1",
"webpack": "^2.3.2"
}
}

最后是我的 src/index.js:

import styles from './main.scss';

console.log('Something.')

提前谢谢您。

最佳答案

答案很明显。我还没有安装 eslint 本身(仅加载器)。安装并创建 .eslint 文件后,它可以正常工作。

关于javascript - 无法在 webpack 中使用 eslint 加载器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43043410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com