electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.42k stars 507 forks source link

Production pruning fails when `yarn` is used to install and `npm@5` is used to prune #249

Closed choffmeister closed 7 years ago

choffmeister commented 7 years ago

I can't believe that others have this problem, too. But I really don't know what else could I test. Here is my minimal example to reproduce the problem (I am using OSX):

$ node --version && npm --version && yarn --version && electron-forge --version
v8.0.0
5.0.1
0.24.5
✔ Checking your system
3.0.5

$ mkdir test

$ cd test

$ electron-forge init
✔ Checking your system
✔ Initializing Project Directory
✔ Initializing Git Repository
✔ Copying Starter Files
✔ Initializing NPM Module
✔ Installing NPM Dependencies

$ yarn make
yarn make v0.24.5
$ electron-forge make
✔ Checking your system
✔ Resolving Forge Config
We need to package your application before we can make it
✔ Preparing to Package Application for arch: x64
✔ Compiling Application
✔ Preparing native dependencies
✔ Packaging Application
Making for the following targets:
✔ Making for target: zip - On platform: darwin - For arch: x64
✨  Done in 15.52s.

$ open out/test-darwin-x64/test.app

So I created a fresh project from scratch, package it and try to open the resulting app. But I get the following error:

A JavaScript error occurred in the main process

Uncaught Exception:
Error: Cannot find module 'electron-compile'
    at Module._resolveFilename (module.js:470:15)
    at Function.Module._resolveFilename (/Users/choffmeister/test/out/test-darwin-x64/test.app/Contents/Resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/choffmeister/test/out/test-darwin-x64/test.app/Contents/Resources/app/es6-shim.js:4:23)
    at Object.<anonymous> (/Users/choffmeister/test/out/test-darwin-x64/test.app/Contents/Resources/app/es6-shim.js:10:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)

Investigating the folder of the app I find, that the folder out/test-darwin-x64/test.app/Contents/Resources/app/node_modules is empty.

Is this an OSX problem?

Thanks for your help!

malept commented 7 years ago

In between init and make, perhaps run yarn?

Although I think "Installing NPM Dependencies" should do that for you...

malept commented 7 years ago

Do you mind running DEBUG='electron-forge:*' electron-forge init in a clean directory?

choffmeister commented 7 years ago

@malept The node_modules/ folder in the project itself is filled. So deps are installed (yarn start also works fine).

Here the output of the debug stuff:

$ mkdir test2

$ cd test2

$ DEBUG='electron-forge:*' electron-forge init
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:lifecycle Process Started: Checking your system +0ms
  electron-forge:lifecycle Process Succeeded: Checking your system +10ms
  electron-forge:runtime-config setting key: verbose to value: false +3ms
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:init Initializing in: /Users/choffmeister/test2 +0ms
  electron-forge:lifecycle Process Started: Initializing Project Directory +1ms
  electron-forge:init:directory creating directory: /Users/choffmeister/test2 +1ms
  electron-forge:lifecycle Process Succeeded: Initializing Project Directory +3ms
  electron-forge:lifecycle Process Started: Initializing Git Repository +0ms
  electron-forge:init:git executing "git init" in directory: /Users/choffmeister/test2 +1ms
  electron-forge:lifecycle Process Succeeded: Initializing Git Repository +14ms
  electron-forge:lifecycle Process Started: Copying Starter Files +0ms
  electron-forge:init:starter-files creating directory: /Users/choffmeister/test2/src +0ms
  electron-forge:init:starter-files copying "/usr/local/lib/node_modules/electron-forge/tmpl/_gitignore" --> "/Users/choffmeister/test2/.gitignore" +1ms
  electron-forge:init:starter-files copying "/usr/local/lib/node_modules/electron-forge/tmpl/_compilerc" --> "/Users/choffmeister/test2/.compilerc" +1ms
  electron-forge:init:starter-files copying "/usr/local/lib/node_modules/electron-forge/tmpl/_eslintrc" --> "/Users/choffmeister/test2/.eslintrc" +0ms
  electron-forge:init:starter-files copying "/usr/local/lib/node_modules/electron-forge/tmpl/index.js" --> "/Users/choffmeister/test2/src/index.js" +0ms
  electron-forge:init:starter-files copying "/usr/local/lib/node_modules/electron-forge/tmpl/index.html" --> "/Users/choffmeister/test2/src/index.html" +1ms
  electron-forge:lifecycle Process Succeeded: Copying Starter Files +0ms
  electron-forge:lifecycle Process Started: Initializing NPM Module +1ms
  electron-forge:init:npm writing package.json to: /Users/choffmeister/test2 +4ms
  electron-forge:lifecycle Process Succeeded: Initializing NPM Module +0ms
  electron-forge:lifecycle Process Started: Installing NPM Dependencies +1ms
  electron-forge:init:npm installing dependencies +0ms
  electron-forge:dependency-installer installing ["electron-compile"] in: /Users/choffmeister/test2 dev=false,exact=false,withYarn=true +173ms
  electron-forge:dependency-installer executing ["add","electron-compile"] in: /Users/choffmeister/test2 +0ms
  electron-forge:runtime-config fetching key verbose +0ms
  electron-forge:runtime-config fetching key verbose +1ms
  electron-forge:init:npm installing devDependencies +3s
  electron-forge:dependency-installer installing ["babel-preset-env","babel-preset-react","babel-plugin-transform-async-to-generator"] in: /Users/choffmeister/test2 dev=true,exact=false,withYarn=true +0ms
  electron-forge:dependency-installer executing ["add","babel-preset-env","babel-preset-react","babel-plugin-transform-async-to-generator","--dev"] in: /Users/choffmeister/test2 +0ms
  electron-forge:runtime-config fetching key verbose +0ms
  electron-forge:runtime-config fetching key verbose +1ms
  electron-forge:init:npm installing exact dependencies +2s
  electron-forge:dependency-installer installing ["electron-prebuilt-compile"] in: /Users/choffmeister/test2 dev=true,exact=true,withYarn=true +1ms
  electron-forge:dependency-installer executing ["add","electron-prebuilt-compile","--dev","--exact"] in: /Users/choffmeister/test2 +0ms
  electron-forge:runtime-config fetching key verbose +0ms
  electron-forge:runtime-config fetching key verbose +1ms
  electron-forge:init:npm installing airbnb linting dependencies +8s
  electron-forge:dependency-installer installing ["eslint","eslint-config-airbnb","eslint-plugin-import","eslint-plugin-jsx-a11y","eslint-plugin-react"] in: /Users/choffmeister/test2 dev=true,exact=false,withYarn=true +1ms
  electron-forge:dependency-installer executing ["add","eslint","eslint-config-airbnb","eslint-plugin-import","eslint-plugin-jsx-a11y","eslint-plugin-react","--dev"] in: /Users/choffmeister/test2 +0ms
  electron-forge:runtime-config fetching key verbose +0ms
  electron-forge:runtime-config fetching key verbose +1ms
  electron-forge:lifecycle Process Succeeded: Installing NPM Dependencies +3s
choffmeister commented 7 years ago

And also the make step as debug:

$ DEBUG='electron-forge:*' electron-forge make
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:lifecycle Process Started: Checking your system +0ms
  electron-forge:lifecycle Process Succeeded: Checking your system +10ms
  electron-forge:runtime-config setting key: verbose to value: false +4ms
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:lifecycle Process Started: Resolving Forge Config +0ms
  electron-forge:project-resolver searching for project in: /Users/choffmeister/test2 +1ms
  electron-forge:project-resolver electron-forge compatible package.json found in /Users/choffmeister/test2/package.json +8ms
  electron-forge:lifecycle Process Succeeded: Resolving Forge Config +3ms
  electron-forge:require-search searching [ '../makers/darwin/zip.js',
  '../makers/generic/zip.js',
  'electron-forge-maker-zip',
  'zip',
  '/Users/choffmeister/test2/zip',
  '/Users/choffmeister/test2/node_modules/zip',
  '/usr/local/lib/node_modules/electron-forge/dist/makers/darwin/zip.js',
  '/usr/local/lib/node_modules/electron-forge/dist/makers/generic/zip.js',
  '/usr/local/lib/node_modules/electron-forge/dist/api/electron-forge-maker-zip',
  '/usr/local/lib/node_modules/electron-forge/dist/api/zip',
  '/Users/choffmeister/test2/zip',
  '/Users/choffmeister/test2/node_modules/zip',
  '/usr/local/lib/node_modules/electron-forge/dist/api/makers/darwin/zip.js',
  '/usr/local/lib/node_modules/electron-forge/dist/api/makers/generic/zip.js',
  '/usr/local/lib/node_modules/electron-forge/dist/api/node_modules/electron-forge-maker-zip',
  '/usr/local/lib/node_modules/electron-forge/dist/api/node_modules/zip',
  '/Users/choffmeister/test2/zip',
  '/Users/choffmeister/test2/node_modules/zip' ] relative to /usr/local/lib/node_modules/electron-forge/dist/api +0ms
  electron-forge:require-search testing ../makers/darwin/zip.js +2ms
  electron-forge:require-search testing ../makers/generic/zip.js +0ms
We need to package your application before we can make it
  electron-forge:lifecycle Process Started: Preparing to Package Application for arch: x64 +14ms
  electron-forge:project-resolver searching for project in: /Users/choffmeister/test2 +0ms
  electron-forge:project-resolver electron-forge compatible package.json found in /Users/choffmeister/test2/package.json +0ms
  electron-forge:hook could not find hook: generateAssets +2ms
  electron-forge:hook could not find hook: prePackage +0ms
  electron-forge:packager packaging with options { asar: false,
  overwrite: true,
  afterCopy: [ [Function], [Function], [Function], [Function] ],
  afterExtract: [],
  dir: '/Users/choffmeister/test2',
  arch: 'x64',
  platform: 'darwin',
  out: '/Users/choffmeister/test2/out',
  electronVersion: '1.6.11',
  quiet: true } +0ms
  electron-forge:lifecycle Process Succeeded: Preparing to Package Application for arch: x64 +6s
  electron-forge:lifecycle Process Started: Compiling Application +2ms
  electron-forge:lifecycle Process Succeeded: Compiling Application +611ms
  electron-forge:lifecycle Process Started: Preparing native dependencies +0ms
  electron-forge:lifecycle Process Succeeded: Preparing native dependencies +38ms
  electron-forge:lifecycle Process Started: Packaging Application +0ms
  electron-forge:hook could not find hook: postPackage +4s
  electron-forge:lifecycle Process Succeeded: Packaging Application +0ms
Making for the following targets:
  electron-forge:hook could not find hook: preMake +1ms
  electron-forge:lifecycle Process Started: Making for target: zip - On platform: darwin - For arch: x64 +1ms
  electron-forge:lifecycle Process Succeeded: Making for target: zip - On platform: darwin - For arch: x64 +5s
  electron-forge:hook could not find hook: postMake +0ms
malept commented 7 years ago

is electron-compile in test2/node_modules? Is it enumerated in package.json?

choffmeister commented 7 years ago

Yes. It is present in test2/node_modules and present as dependency in package.json.

choffmeister commented 7 years ago

@malept Is it normal, that he can't find some of the hooks like preMake, postMake...? Also just tried removing electron-forge globally and reinstalling afterwards. Did not help.

NuroDev commented 7 years ago

Also been having this issue. Can't tell why though the make command is not installing the needed dependencies 😕

MarshallOfSound commented 7 years ago

What npm version are you guys running?

MarshallOfSound commented 7 years ago

@Meadowcottage make doesn't install anything, your existing node_modules installation is copied and used

@choffmeister Can you drop back to npm@3 and see if it starts working again. I known npm@4 and @5 have some pretty big issues with pruning production dependencies and I always use @3 for everything because of this 😄

NuroDev commented 7 years ago

Ah okay. Didn't know that. I'n running npm version: 5.0.3. And just on a side note. I am running yarn version: 0.24.5.

choffmeister commented 7 years ago
$ node --version && npm --version && yarn --version && electron-forge --version
v8.0.0
5.0.1
0.24.5
✔ Checking your system
3.0.5

I will try the npm3 thing. Although it should not make a difference, because the packages are there and working for yarn start to work. Only the copying into out/..../node_modules does not do a thing.

MarshallOfSound commented 7 years ago

Although it should not make a difference

Behind the scenes Electron Packager runs npm prune --production on your node_modules folder when packaging.

npm@4/5 don't do that very well afaik

MarshallOfSound commented 7 years ago

The other thing you guys can try is setting yarn to be the tool used for pruning packages.

packageManager: 'yarn'

https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#packagemanager

choffmeister commented 7 years ago

@MarshallOfSound You had the right idea. I tested making inside of the docker image electronuserland/electron-builder:wine. This image per default has npm@5. When I explicitly downgrade with npm install -g npm@3 before making it works. Else not.

MarshallOfSound commented 7 years ago

@choffmeister I think this is something that needs to be minimally reproed and raised on the npm repository for them to figure out. On our end we can add an npm version check to the "Checking your system" step of electron-forge and warn people npm@5 doesn't work too well.

choffmeister commented 7 years ago

@MarshallOfSound Yes. I hope that the NPM guys get v5 fixed soon. Thanks for your help!

choffmeister commented 7 years ago

@MarshallOfSound I found the real issue. The problem with npm@5 is not, that it is generally broken. The problem is that when creating a project with electron-forge init that yarn is used. So there only is a yarn.lock but no package-lock.json from npm@5. That is why electron-forge make with npm@5 installed does not copy over node modules.

So from that point I would say it is an issue of electron-forge. Either:

  1. Keep using yarn with electron-forge, but then you must configure it as packagemanger for electron-packager by default
  2. Use npm with electron-forge.
MarshallOfSound commented 7 years ago

@malept I think the best thing to do here if @choffmeister's analysis is correct is to modify your PR #216 so that it sets the packageManager property on init based on what was used to install modules. Then the value is set based on the install not based on what is currently available but can be changed at any time.

We should also add some validation so if yarn is used but no yarn.lock we should warn the user. And if npm@5 is used an no package-lock.json is present we should error out.

andrewdavidmackenzie commented 6 years ago

Do you usually mark both issues as "duplicate"? It makes it hard to know which is the canonical one to follow.

Either way, a change has been merged and issue closed, but a download of electron-forge today (literally, I tried it today - Nov 4 2017) still exhibits the issue.

I had npm@5 installed and downgraded to npm@3 and that fixed it.

Is a new release with the fix planned or is there something I am missing?

thanks

malept commented 6 years ago

I'm not seeing a mention of this as a duplicate.

What version of NPM 5 were you using?

andrewdavidmackenzie commented 6 years ago
screen shot 2017-11-04 at 20 46 58

Directly above my comment.

I'm not sure what version of npm 5 I had, as I have now downgraded (unless there is a history around somewhere?)

malept commented 6 years ago

Oh, weird GitHub duplicate marking. I didn't see it because I'm on mobile.

Was your NPM the default that came with Node? If so, what version of Node do you have installed?

andrewdavidmackenzie commented 6 years ago

I can now reproduce this with node 3 or node 5, so I think is some other dependency.

As I was having Travis-CI problems anyway, I'm now running this in a clean docker image of travis-ci. You should be able to reproduce this using docker and get exactly the same machine and installed dependencies as me.

> docker run -it quay.io/travisci/travis-node-js /bin/bash

root@eb968386aa59:/# su - travis

travis@38866b4f2a40:git clone https://github.com/andrewdavidmackenzie/flowui.git

travis@38866b4f2a40:cd flowui

travis@eb968386aa59:~$ nvm install 8
######################################################################## 100.0%
Checksums empty
Now using node v8.9.0

travis@38866b4f2a40:~/flowui$ npm -v
5.5.1

travis@eb968386aa59:~$ npm install electron-forge
npm WARN deprecated wrench@1.5.9: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

> electron-forge@4.1.2 install /home/travis/node_modules/electron-forge
> node tabtab-install.js

[tabtab] Adding source line to load /home/travis/node_modules/tabtab/.completions/electron-forge.bash
in /home/travis/.bashrc

> spawn-sync@1.0.15 postinstall /home/travis/node_modules/spawn-sync
> node postinstall

npm WARN saveError ENOENT: no such file or directory, open '/home/travis/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/travis/package.json'
npm WARN travis No description
npm WARN travis No repository field.
npm WARN travis No README data
npm WARN travis No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: appdmg@0.4.5 (node_modules/appdmg):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for appdmg@0.4.5: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ electron-forge@4.1.2
added 596 packages in 36.32s

travis@38866b4f2a40:~/flowui$ electron-forge --version
✔ Checking your system
4.1.2

travis@38866b4f2a40:~/flowui$ electron-forge make
travis@4c029925e6e5:~/flowui$ electron-forge make
✔ Checking your system
✔ Resolving Forge Config
We need to package your application before we can make it
Downloading tmp-616-1-SHASUMS256.txt-1.7.9
[============================================>] 100.0% of 2.93 kB (2.93 kB/s)
✔ Preparing to Package Application for arch: x64
✖ Compiling Application

An unhandled error has occurred inside Forge:
Cannot find module '/home/travis/flowui/node_modules/electron-compile/lib/cli.js'
Error: Cannot find module '/home/travis/flowui/node_modules/electron-compile/lib/cli.js'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at _callee2$ (/home/travis/flowui/node_modules/electron-forge/dist/util/compile-hook.js:181:36)
    at tryCatch (/home/travis/flowui/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (/home/travis/flowui/node_modules/regenerator-runtime/runtime.js:299:22)
    at Generator.prototype.(anonymous function) [as next] (/home/travis/flowui/node_modules/regenerator-runtime/runtime.js:117:21)
    at Generator.tryCatcher (/home/travis/flowui/node_modules/bluebird/js/release/util.js:16:23)
    at PromiseSpawn._promiseFulfilled (/home/travis/flowui/node_modules/bluebird/js/release/generators.js:97:49)
    at /home/travis/flowui/node_modules/bluebird/js/release/generators.js:201:15
    at /home/travis/flowui/node_modules/electron-forge/dist/util/ora-handler.js:70:5
    at new Promise (<anonymous>)
    at new F (/home/travis/flowui/node_modules/core-js/library/modules/_export.js:35:28)
    at asyncOra (/home/travis/flowui/node_modules/electron-forge/dist/util/ora-handler.js:69:10)
    at _callee3$ (/home/travis/flowui/node_modules/electron-forge/dist/util/compile-hook.js:46:45)
malept commented 6 years ago

It seems like npm install (to install your project's dependencies, not just electron-forge) isn't called at all here. That's why electron-compile isn't found.

andrewdavidmackenzie commented 6 years ago

Ouch! You can tell I'm an npm newbie...

That got things further at least, the .deb build worked and then the .rpm build failed, so some other issues I need to investigate.

Thanks for the patience and sorry for wasting your time.

DaBrown95 commented 6 years ago

As @MarshallOfSound suggested, adding "packageManager": "yarn" to "electronPackagerConfig" solved the issues for me.

alairock commented 6 years ago

Vanilla app build here on MacOS. Adding "packageManager": "yarn" seems to fail to compile, saying it couldn't find module "extract-zip".

  "dependencies": {
    "electron-compile": "^6.4.2",
    "electron-devtools-installer": "^2.1.0",
    "electron-squirrel-startup": "^1.0.0",
    "extract-zip": "^1.6.6",
    "react": "^15.4.1",
    "react-dom": "^15.4.1",
    "react-hot-loader": "^3.0.0-beta.6"
  },
  "devDependencies": {
    "babel-plugin-transform-async-to-generator": "^6.24.1",
    "babel-plugin-transform-es2015-classes": "^6.24.1",
    "babel-preset-env": "^1.6.1",
    "babel-preset-react": "^6.24.1",
    "electron-compilers": "^5.9.0",
    "electron-forge": "^5.1.1",
    "electron-prebuilt-compile": "1.8.4",
    "eslint": "^3",
    "eslint-config-airbnb": "^15",
    "eslint-plugin-import": "^2",
    "eslint-plugin-jsx-a11y": "^5",
    "eslint-plugin-react": "^7"
  }
malept commented 6 years ago

@alairock What's the actual console output?

alairock commented 6 years ago
✔ Compiling Application

An unhandled rejection has occurred inside Forge:
Command failed: yarn install --production --no-bin-links --no-lockfile
warning electron-compilers > coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
warning electron-compilers > cson > coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
warning electron-compilers > jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
warning electron-compilers > jade > constantinople@3.0.2: Please update to at least constantinople 3.1.1
warning electron-compilers > jade > transformers@2.1.0: Deprecated, use jstransformer
warning electron-forge > s3 > graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
warning electron-forge > zip-folder > archiver > glob > minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning electron-forge > electron-windows-store > flatten-packages > wrench@1.5.9: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.
warning electron-forge > nugget > progress-stream > through2 > xtend > object-keys@0.4.0:
error //npm-electron-1.8.4-cca8d0e6889f238f55b414ad224f03e03b226a38: Command failed.
Exit code: 1
Command: sh
Arguments: -c node install.js
Directory: /npm-electron-1.8.4-cca8d0e6889f238f55b414ad224f03e03b226a38
Output:
module.js:487
    throw err;
    ^

Error: Cannot find module 'extract-zip'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/npm-electron-1.8.4-cca8d0e6889f238f55b414ad224f03e03b226a38/install.js:8:15)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

Error: Command failed: yarn install --production --no-bin-links --no-lockfile
warning electron-compilers > coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
warning electron-compilers > cson > coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
warning electron-compilers > jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
warning electron-compilers > jade > constantinople@3.0.2: Please update to at least constantinople 3.1.1
warning electron-compilers > jade > transformers@2.1.0: Deprecated, use jstransformer
warning electron-forge > s3 > graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
warning electron-forge > zip-folder > archiver > glob > minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning electron-forge > electron-windows-store > flatten-packages > wrench@1.5.9: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.
warning electron-forge > nugget > progress-stream > through2 > xtend > object-keys@0.4.0:
error //npm-electron-1.8.4-cca8d0e6889f238f55b414ad224f03e03b226a38: Command failed.
Exit code: 1
Command: sh
Arguments: -c node install.js
Directory: /npm-electron-1.8.4-cca8d0e6889f238f55b414ad224f03e03b226a38
Output:
module.js:487
    throw err;
    ^

Error: Cannot find module 'extract-zip'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/npm-electron-1.8.4-cca8d0e6889f238f55b414ad224f03e03b226a38/install.js:8:15)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

    at ChildProcess.exithandler (child_process.js:270:12)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:897:16)
    at Socket.stream.socket.on (internal/child_process.js:340:11)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at Pipe._handle.close [as _onclose] (net.js:549:12)
malept commented 6 years ago

That doesn't make any sense to me. What does your Forge config look like?

alairock commented 6 years ago
    "forge": {
      "make_targets": {
        "win32": [
          "squirrel"
        ],
        "darwin": [
          "zip"
        ],
        "linux": [
          "deb",
          "rpm"
        ]
      },
      "electronPackagerConfig": {
        "packageManager": "npm",
        "ignore": [".idea"]
      },
      "electronWinstallerConfig": {
        "name": "binaryclock"
      },
      "electronInstallerDebian": {},
      "electronInstallerRedhat": {},
      "github_repository": {
        "owner": "",
        "name": ""
      },
      "windowsStoreConfig": {
        "packageName": "",
        "name": "binaryclock"
      }
    }
  },
malept commented 6 years ago

electronPackagerConfig.ignore should be ['\\.idea'] because it's a regular expression, but that shouldn't matter.

Have you tried wiping out the node_modules directory and reinstalling that? If that doesn't work, try setting electronPackagerConfig.packageManager to false (the boolean, not a string).

xn commented 6 years ago

@malept I'm running into the same problem and setting electronPackagerConfig.packageManager to false worked for me.

malept commented 6 years ago

@xn this is not surprising, I have electron-userland/electron-packager#819 to drop support for using NPM/yarn/cnpm to prune.

xn commented 6 years ago

Thanks for the help. I appreciate it.

misaxi commented 6 years ago

Is this really solved? I follow the instruction and still get the same error message

npx @electron-forge/cli init my-app
cd my-app
npm run make

it prompts me electron-prebuilt-compile is required

npm i -DE electron-prebuilt-compile
npm run make

Then I go to unzip and run the app, got the following error

Uncaught Exception:
Error: Cannot find module 'electron-compile'
malept commented 6 years ago

A few things:

@MarshallOfSound can we "deprecate" 6.0.0-beta.1? When I have some time I'm going to change the quick start instructions to add @beta (feel free to do it first).

Acccent commented 6 years ago

Hi,

I've been running into the same issue, and I don't know where to change forge.config.electronPackagerConfig.packageManager to fix it. I set { "config": { "forge": { "packagerConfig": false, ... } } } in package.json, but to no avail.

Could you help me out please? Sorry about the probably newbie question :)

malept commented 6 years ago

@Acccent please run electron-forge --version to see which version of Electron Forge you're running. (If you don't have it installed globally, I guess npm run package -- --version?)

In my earlier comment there are different instructions for Electron Forge 5 (and below) and Electron Forge 6 (and above).

Acccent commented 6 years ago

@malept I have 5.2.2 (installed locally), so I tried following the instructions for 5 and below (setting packageManager to false) but didn't really manage it.

malept commented 6 years ago

This works for me:

https://github.com/malept/electron-forge-demo123/blob/52e55ba20e8c97973c12697794c89abe05d0b5af/package.json#L30-L32

misaxi commented 6 years ago

Just a quick update. After I switched to ver 5, even without configuring packageManager, it’s working out of the box.

Acccent commented 6 years ago

Ok so 1) I got confused about the config file because what needed to be set to false is config.forge.electronPackagerConfig.packageManager, not forge.config.electronPackagerConfig.packageManager 2) however I'm not sure that even mattered, because it turns out electron-compile had never been installed? I don't know if that's normal or not. After I installed it manually it worked fine :)

mran3 commented 4 years ago

Same as @Acccent, my problem when running the packaged application on windows was solved after installing electron-compile manually in the project.