Webpack - Module not found: Error: Can't resolve 'node_modules\chokidar\lib'

Tryall Allombria

When I compile my Electron application with the npm package "Electron-reload". I got an error. Apprently, Electron-reload use chokidar to watch my applications files, so It can reload it when a file change is detected.

The error I have when compiling my electron main process with webpack :

WARNING in ./node_modules/chokidar/lib/fsevents-handler.js
Module not found: Error: Can't resolve 'fsevents' in 
'C:\[...]\node_modules\chokidar\lib'

And the error I have when my electron application is running :

TypeError: Cannot read property 'filename' of undefined
 at Object.eval (webpack:///./node_modules/electron-reload/main.js?:12:32)
 at eval (webpack:///./node_modules/electron-reload/main.js?:86:30)
 at Object../node_modules/electron-reload/main.js (C:\[...]\Dist\Electron\app.js:322:1)
 at __webpack_require__ (C:\[...]\Dist\Electron\app.js:20:30)
 at eval (webpack:///./Electron/app.ts?:5:5)
 at Object../Electron/app.ts (C:\[...]\Dist\Electron\app.js:109:1)
 at __webpack_require__ (C:[...]\Dist\Electron\app.js:20:30)
 at C:\[...]\Dist\Electron\app.js:84:18
 at Object.<anonymous> (C:\[...]\Dist\Electron\app.js:87:10)
 at Module._compile (internal/modules/cjs/loader.js:1145:30)

I can't find anything useful online from Electron-reload, chokidar or webpack. Here is my webpack.config.js

const path = require('path');
module.exports = {
    mode: "development",
    entry: "./Electron/app.ts",
    target: "electron-main",
    module: "es6",
    watch: true,
    stats: 'minimal',
    output: {
        path: path.resolve(__dirname, "./Dist/Electron/"),
        filename: "app.js",
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: 'ts-loader',
                include: /Electron/,
            },
        ]
    },

    resolve: {
        extensions: ['.ts', '.tsx', '.js']
    }
}

thank you for your help.

Tryall Allombria

Okay, I didn't resolved the original problem. But since I only wanted to reload my electron render process when a file is changed, I found another way of doing it without "Electron-Reload"

Inside the function that render my main window I added :

import {join} from 'path';
import {watch} from 'fs';

app.whenReady().then(()=>{
   watch('./Dist/Client/', (eventType, filename)=>{ win.reload(); })
} 

Everything is working fine now.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

webpack: Module not found: Error: Can't resolve (with relative path)

Webpack 4 : ERROR in Entry module not found: Error: Can't resolve './src'

Error: Module not found: Error: Can't resolve '@angular/cdk/scrolling'

webpack Module not found: Error: Can't resolve 'jquery'

Module not found: Error: Can't resolve 'hammerjs'

Module not found: Error: Can't resolve 'fs'

Webpack Upgrade - Module not found: Can't resolve node_modules

Module not found: Error: Can't resolve 'bundle.js' in '/Users/jonathankuhl/Documents/Programming/node js/sandbox/webpack-app'

Webpack 4: ERROR in Entry module not found: Error: Can't resolve './src'

Module not found: Error: Can't resolve 'avoriaz'

Module not found: Error: Can't resolve './templates'

webpack - Module not found: Error: Can't resolve './src/app/app.component.html'

How to fix "Module not found: Error: Can't resolve *" error

Webpack: npm start "Module not found: Error: Can't resolve ..." after moving location for webpack / react files

Module not found: Error: Can't resolve 'dropzone'

Module not found: Error: Can't resolve 'module

Webpack "Module not found: Error: Can't resolve '../webfonts/fa-solid-900.eot' "

got error Module not found: Error: Can't resolve '../components/***' when webpack build,how can I solve this problem?

ERROR in "path" Module not found: Error: Can't resolve - Angular 6 Webpack

[React Webpack]: Module not found: Error: Can't resolve 'src/views/UserList' in 'C:\Users\....'

Webpack parse module path. Module not found: Error: Can't resolve './internal/Observable' in

Webpack Module not found: Error: Cannot resolve module

Webpack css-loader: "Module not found: Error: Can't resolve 'main.css' in ..."

Module not found: Error: Can't resolve 'ReactDOM'

webpack Module not found: Error: Can't resolve classNames

Module not found: Error: Can't resolve 'uuid' in

MUI : Module not found "Module not found: Error: Can't resolve 'moment' "

Module not found: Error: Can't resolve 'util'

Module not found: Error: Can't resolve './components'