Electron-builder: "install-app-deps" fails during 'npm install'

Created on 4 May 2016  路  6Comments  路  Source: electron-userland/electron-builder

Node 4.2.1
NPM 2.14.7
electron-builder ~3.16.1
Win7 64x

npm install fails if I include "postinstall": "install-app-deps" in my package.json scripts section. I'm only using 1 package.json file. If I do not include "postinstall": "install-app-deps" the npm install works fine.

As you can see below it also is looping though the installing app dependencies for arch x64 part several times and I cant figure out why.

$ npm i

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit

> [email protected] postinstall C:\apps\myApps\electron-starter-kit
> install-app-deps

Installing app dependencies for arch x64 to C:\apps\myApps\electron-starter-kit
C:\Program Files\nodejs\node_modules\npm\node_modules\osenv\osenv.js:54
  return osHomedir()
         ^

Error: EIO: i/o error, uv_os_homedir
    at Error (native)
    at C:\Program Files\nodejs\node_modules\npm\node_modules\osenv\osenv.js:54:10
    at Object.exports.(anonymous function) [as home] (C:\Program Files\nodejs\node_modules\npm\node_modules\osenv\osenv.js:15:15)
    at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\config\defaults.js:77:18)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
Unhandled rejection Error: C:\Program Files\nodejs\node.exe exited with code 1
    at ChildProcess.<anonymous> (C:\apps\myApps\electron-starter-kit\node_modules\electron-builder\src\util.ts:106:69)

    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:818:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
From previous event:
    at spawn (C:\apps\myApps\electron-starter-kit\node_modules\electron-builder\src\util.ts:104:9)
    at Object.installDependencies (C:\apps\myApps\electron-starter-kit\node_modules\electron-builder\src\util.ts:48:9)

    at C:\apps\myApps\electron-starter-kit\node_modules\electron-builder\src\install-app-deps.ts:26:2
    at [object Generator].next (native)
    at processImmediate [as _immediateCallback] (timers.js:368:17)
From previous event:
    at tsAwaiter (C:\apps\myApps\electron-starter-kit\node_modules\electron-builder\src\awaiter.ts:10:47)
    at main (C:\apps\myApps\electron-starter-kit\node_modules\electron-builder\src\install-app-deps.ts:19:3)
    at Object.<anonymous> (C:\apps\myApps\electron-starter-kit\node_modules\electron-builder\src\install-app-deps.ts:31:7)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:134:18)
    at node.js:961:3
question windows

Most helpful comment

If you don't use two package.json structure, don't specify "postinstall": "install-app-deps Thanks for report, docs fixed.

All 6 comments

It is your system issue, please see https://github.com/npm/npm/issues/3538#issuecomment-34990447

I had the same problem. It's because there isn't an app/package.json file and npm install starts recursing creating nested npm install processes until it throws with the posted error.

According to documentation this the _two package.json structure_ is optional, so I think this issue should be re-open.

The steps to reproduce it would be:

  • install electron-builder
  • configure package.json postinstall: "postinstall": "install-app-deps
  • Delete app folder (if any)
  • run npm install

If you don't use two package.json structure, don't specify "postinstall": "install-app-deps Thanks for report, docs fixed.

Thx @develar now I see that documentation already states that.
One good thing is that the problem and solution are now documented in this issue.

Anyway, I still think that the program should prevent the recursion as it's an easy mistake to make. I believe the problem is in install-app-deps.ts calls util.ts computeDefaultAppDirectory and if no app directory was found it returns the project directory, starting the npm install recursion.

I have two package.json files (in root and app/ folders) and have this error.
win 10, node v5.12, electron 1.3.3

Got the issue and I am in Docker Linux. I use yarn workspace. I haven't experienced it on host though.

[Update]

I just checked and I have node_modules/.bin/install-app-deps binary on host.

[Update]

I logged into my intermediate container and it fails too.

However, I notice that node_modules/.bin/install-app-deps exists not yet.

As if the electron-builder bin instruction failed to be installed before my package postinstall.

[Update]

I just check what's installed and the only electron* dependency installed is electron-to-chromium.

$ yarn why electron-to-chromium
yarn why v1.22.4
[1/4] Why do we have the module "electron-to-chromium"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "[email protected]"
info Reasons this module exists
   - "_project_#browserslist" depends on it
   - Hoisted from "_project_#browserslist#electron-to-chromium"
   - Hoisted from "_project_#@nstudio#web-angular#@nstudio#web#@nrwl#web#browserslist#electron-to-chromium"
info Disk size without dependencies: "72KB"
info Disk size with unique dependencies: "72KB"
info Disk size with transitive dependencies: "72KB"
info Number of shared dependencies: 0
Done in 1.53s.

I should be debugging why electron-builder is not installed.

[Update]

Found out electron-builder is part of a different workspace which I didn't add to my Dockerfile. But the "postinstall" config happen to be in the root package.json.

[Update]

Fixing workspace issue fixed the issue for me.

Was this page helpful?
0 / 5 - 0 ratings