'Module build failed (from ./node_modules/html-loader/dist/cjs.js):

I'm trying to make a quick-start for ava electron webpack and three but something went wrong in that process.

here is the repository of the project :

https://github.com/etiennerin/ecsy-three-electron-ava-quick-start

By simply trying to use my project by typing npm run dev i get the following error message :

npm run dev output

I'm using windows.

I think the mistake might be related with my webpack-configuration which strangely seemed to work befor i tried some npm-update :

'use strict'

import { app, BrowserWindow } from 'electron'
import * as path from 'path'
import { format as formatUrl } from 'url'
import * as THREE from '../../node_modules/three/build/three.module.js';
//import {World} from '../../node_modules/ecsy/build/ecsy.module.js';

const isDevelopment = process.env.NODE_ENV !== 'production'

// global reference to mainWindow (necessary to prevent window from being garbage collected)
let mainWindow

function createMainWindow() {
  const window = new BrowserWindow({webPreferences: {nodeIntegration: true}})

  if (isDevelopment) {
    window.webContents.openDevTools()
  }

  if (isDevelopment) {
    window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`)
  }
  else {
    window.loadURL(formatUrl({
      pathname: path.join(__dirname, 'index.html'),
      protocol: 'file',
      slashes: true
    }))
  }

  window.on('closed', () => {
    mainWindow = null
  })

  window.webContents.on('devtools-opened', () => {
    window.focus()
    setImmediate(() => {
      window.focus()
    })
  })

  return window
}

// quit application when all windows are closed
app.on('window-all-closed', () => {
  // on macOS it is common for applications to stay open until the user explicitly quits
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  // on macOS it is common to re-create a window even after all windows have been closed
  if (mainWindow === null) {
    mainWindow = createMainWindow()
  }
})

// create main BrowserWindow when electron is ready
app.on('ready', () => {
  mainWindow = createMainWindow()
})

and my latest package.json :

{
  "name": "electron-webpack-quick-start",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "start": "electron-webpack dev",
    "dev": "electron-webpack dev",
    "compile": "electron-webpack",
    "dist": "yarn compile && electron-builder",
    "dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null",
    "test": "ava"
  },
  "dependencies": {
    "source-map-support": "^0.5.16"
  },
  "ava": {
    "files": [
      "spec/**/*"
    ],
    "require": [
      "esm"
    ]
  },
  "devDependencies": {
    "ava": "^3.5.1",
    "ecsy": "^0.2.3",
    "electron": "8.1.1",
    "electron-builder": "^22.4.1",
    "electron-webpack": "^2.7.4",
    "esm": "^3.2.25",
    "html-loader": "^1.0.0",
    "three": "^0.112.1",
    "webpack": "^4.42.0"
  }
}

Thank you very much for every piece of advice !



Solution 1:[1]

I also meet the same issue, but I have solved it by looking the .lock file, the html-loader now is v1.0.0[2020.3.19 updated!], Please note this is a completely rewritten loader, it is not based on html-loader-v1.0.0-alpha, so you need to add "html-loader": "1.0.0-alpha.0" to your "devDependencies" in the package.json file.

At the second you should run this command rm -rf node_module && rm -rf yarn.lock && yarn install

For more detail look at this link.

Solution 2:[2]

Have you try to clean and reinstall

rm -rf node_modules yarn.lock package-lock.json
npm install // or yarn
run webpack

Solution 3:[3]

  1. remove expose-loader from packages.json,

  2. Remove from .lock and module

rm -rf node_modules yarn.lock

  1. then resinstall dependencies minus expose loader

yarn install

  1. The issue is coming from expose loader, change the configuration in the

config/webpack/environment to


const webpack = require("webpack")
environment.plugins.append("Provide", new webpack.ProvidePlugin({

  $: 'jquery',
  
  jQuery: 'jquery',
  
  Popper: ['popper.js', 'default']
  
  }))

This should work, for rails 6

Solution 4:[4]

Try this in your package.json:

Change:

"start": "react-scripts start"

To:

"start": "react-scripts --openssl-legacy-provider start"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mohammad javad ahmadi
Solution 2 xdeepakv
Solution 3 Addo
Solution 4 Tyler2P