question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

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!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:45 (19 by maintainers)

github_iconTop GitHub Comments

3reactions
DaBrown95commented, Nov 14, 2017

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

3reactions
MarshallOfSoundcommented, Jun 22, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Production pruning fails when yarn is used to install and npm ...
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 ...
Read more >
yarn prune
The prune command isn't necessary. yarn install will prune extraneous packages. ← yarn policies yarn publish → · CLI Introduction · yarn add...
Read more >
npm prune removes used packages, leaving build broken ...
It seems to take --depth option into account and fails miserably on flat dependency lists. So, fix for the issue was: npm config...
Read more >
CHANGELOG.md ... - GitLab
Do not fail build on output errors · Do not prune before install (shrinkwrap unsupported by prune) · Extended warnings (missing dependencies, econnreset,...
Read more >
npm Blog Archive: v5.7.0
This release brings a bunch of exciting new features and bug fixes. PACKAGE-LOCK GIT MERGE CONFLICT RESOLUTION. Allow npm install to fix package ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found