4

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 !

5 Answers 5

8

Have you try to clean and reinstall

rm -rf node_modules yarn.lock package-lock.json
npm install // or yarn
run webpack
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for your help, yes i did but unfortunately it did not fix my issue, i also pulled it from github again(without all the dist,package-lock,node-modules files, same result) i don't know if this changes anything but i'm using electron-webpack but still it uses webpack in the same way as usual.
Most prob check ur package.json version. If you use * or ^. It update with time. Try to match with package-lock.json. And fix the version in package.json
Thanks again, but still i could'nt figure out the problem, i just got back a few version on my git but this contains 2 security alerts to take into consideration , i even looked all latest version on the npm website and didn't find a viable solution
5

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.

1 Comment

Thanks, indeed it works, but as soon as i type npm run audit fix it stops working, because there are two major security issues and 1 moderate which i'm trying to get rid of.
0
  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

Comments

0

Try this in your package.json:

Change:

"start": "react-scripts start"

To:

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

Comments

0

I also had the similar issue in a Laravel project when compiling assets. Clearing node packages and re-installing them fixed the problem. Try following commands

rm -rf node_modules package-lock.json
npm install

If you're using yarn use yarn.lock instead of package-lock.json

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.