I'm getting familiar to webpack. And it went well before I tried to add eslint loader to my webpack config. I got
ERROR in ./src/index.js Module build failed: Error: Cannot find module 'eslint'
in my console when run webpack command. Here's my 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/
}]
}
}
My 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"
}
}
And finally my src/index.js:
import styles from './main.scss';
console.log('Something.')
Thank you in advance.
The answer is pretty obvious. I haven't installed eslint itself (loader only). After installation and .eslint file creation it works OK.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.