Привет.
Пытаюсь написать приложение на Electron + Webpack.
Обнаружил что многие библиотеки вызывают ошибку вида
Module not found: Error: Can't resolve ...
Например, библиотека
chokidar
.
webpack.config.jsconst path = require('path')
module.exports = {
mode: 'development',
target: `electron-main`,
entry: {main: `./src/main.js`},
resolve: {
extensions: ['.js'],
modules: ['node_modules', path.join(__dirname, 'src')],
},
output: {
path: path.resolve(__dirname, `dist`),
filename: '[name].bundle.js',
},
}
src/main.jsconst watcher = require('chokidar').watch('./dist')
watcher.on('change', function() {
console.log('change', arguments)
})
package.json{
"name": "test",
"version": "1.0.0",
"author": "I",
"private": true,
"main": "dist/main.bundle.js",
"scripts": {
"build": "webpack"
},
"devDependencies": {
"@types/chokidar": "^1.7.5",
"chokidar": "^2.0.4",
"electron": "^2.0.8",
"webpack": "^4.17.1",
"webpack-cli": "^3.1.0"
}
}
При сборке получаем ворнинг:
WARNING in ./node_modules/chokidar/lib/fsevents-handler.js
Module not found: Error: Can't resolve 'fsevents' in '.\node_modules\chokidar\lib'
@ ./node_modules/chokidar/lib/fsevents-handler.js
@ ./node_modules/chokidar/index.js
@ ./src/main.js
Где проблема?
Добавление
node: { fsevents: 'empty' }
не помогает.