Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial setup. Electron app error. #84

Closed
ph55 opened this issue Feb 20, 2019 · 5 comments · Fixed by #86
Closed

Initial setup. Electron app error. #84

ph55 opened this issue Feb 20, 2019 · 5 comments · Fixed by #86

Comments

@ph55
Copy link

ph55 commented Feb 20, 2019

Trying to run initial setup.

npm install -g @nrwl/schematics
npm install -g @angular/cli
create-nx-workspace apps-xplat

npm install @nstudio/schematics --save-dev
ng g xplat --prefix=foo --platforms=web,nativescript,ionic,electron,nest
ng g app devops
ng g app.electron devops --target=web-devops

All good until this point.
But after npm i error appear.

Something related to fsevents and node 11.7 I guess.
These lines are interesting I think:

WARN Pre-built binaries not found for fsevents@1.2.7 and electron@2.0.8
WARN Pre-built binaries not installable for fsevents@1.2.7 and electron@2.0.8

Full error:

npm WARN deprecated joi@9.2.0: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead
npm WARN deprecated socks@1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0

> apps-xplat@0.0.0 postinstall /Users/sasha/Dev/apps-xplat
> ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true npx electron-builder install-app-deps

  • electron-builder version=20.28.4
  • Unresolved node modules: @angular/http
  • rebuilding native production dependencies platform=darwin arch=x64
Error: /usr/local/Cellar/node/11.7.0/bin/node exited with code 1
Output:

> fsevents@1.2.7 install /Users/sasha/Dev/apps-xplat/node_modules/fsevents
> node install

  SOLINK_MODULE(target) Release/.node
  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node
Failed to execute '/usr/local/Cellar/node/11.7.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/sasha/Dev/apps-xplat/node_modules/fsevents/lib/binding/Release/electron-v2.0-darwin-x64/fse.node --module_name=fse --module_path=/Users/sasha/Dev/apps-xplat/node_modules/fsevents/lib/binding/Release/electron-v2.0-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
  COPY /Users/sasha/Dev/apps-xplat/node_modules/fsevents/lib/binding/Release/electron-v2.0-darwin-x64/fse.node
  TOUCH Release/obj.target/action_after_build.stamp

Error output:
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.7/fse-v1.2.7-electron-v2.0-darwin-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for fsevents@1.2.7 and electron@2.0.8 (electron-v2.0 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.7 and electron@2.0.8 (electron-v2.0 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error Connection closed while downloading tarball file
rm: ./Release/.deps/Release/obj.target/fse/fsevents.o.d.raw: No such file or directory
make: *** [Release/obj.target/fse/fsevents.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:188:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/Cellar/node/11.7.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/sasha/Dev/apps-xplat/node_modules/fsevents/lib/binding/Release/electron-v2.0-darwin-x64/fse.node" "--module_name=fse" "--module_path=/Users/sasha/Dev/apps-xplat/node_modules/fsevents/lib/binding/Release/electron-v2.0-darwin-x64" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /Users/sasha/Dev/apps-xplat/node_modules/fsevents
gyp ERR! node -v v11.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/11.7.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/sasha/Dev/apps-xplat/node_modules/fsevents/lib/binding/Release/electron-v2.0-darwin-x64/fse.node --module_name=fse --module_path=/Users/sasha/Dev/apps-xplat/node_modules/fsevents/lib/binding/Release/electron-v2.0-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/sasha/Dev/apps-xplat/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:188:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:978:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
node-pre-gyp ERR! System Darwin 18.2.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/11.7.0/bin/node" "/Users/sasha/Dev/apps-xplat/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/sasha/Dev/apps-xplat/node_modules/fsevents
node-pre-gyp ERR! node -v v11.7.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fsevents@1.2.7 install: `node install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fsevents@1.2.7 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sasha/.npm/_logs/2019-02-20T22_21_46_544Z-debug.log

    at ChildProcess.childProcess.once.code (/Users/sasha/Dev/apps-xplat/node_modules/builder-util/src/util.ts:254:14)
    at Object.onceWrapper (events.js:276:13)
    at ChildProcess.emit (events.js:188:13)
    at maybeClose (internal/child_process.js:978:16)
    at Socket.stream.socket.on (internal/child_process.js:395:11)
    at Socket.emit (events.js:188:13)
    at Pipe._handle.close (net.js:609:12)
From previous event:
    at rebuild (/Users/sasha/Dev/apps-xplat/node_modules/app-builder-lib/out/util/yarn.js:239:18)
    at /Users/sasha/Dev/apps-xplat/node_modules/app-builder-lib/src/util/yarn.ts:20:11
From previous event:
    at installOrRebuild (/Users/sasha/Dev/apps-xplat/node_modules/app-builder-lib/out/util/yarn.js:68:17)
    at /Users/sasha/Dev/apps-xplat/node_modules/electron-builder/src/cli/install-app-deps.ts:56:9
    at Generator.next (<anonymous>)
From previous event:
    at installAppDeps (/Users/sasha/Dev/apps-xplat/node_modules/electron-builder/out/cli/install-app-deps.js:174:17)
    at then (/Users/sasha/Dev/apps-xplat/node_modules/electron-builder/src/cli/cli.ts:42:48)
    at processImmediate (timers.js:632:19)
From previous event:
    at Object.args [as handler] (/Users/sasha/Dev/apps-xplat/node_modules/electron-builder/src/cli/cli.ts:42:48)
    at Object.runCommand (/Users/sasha/Dev/apps-xplat/node_modules/electron-builder/node_modules/yargs/lib/command.js:238:44)
    at Object.parseArgs [as _parseArgs] (/Users/sasha/Dev/apps-xplat/node_modules/electron-builder/node_modules/yargs/yargs.js:1063:30)
    at Object.get [as argv] (/Users/sasha/Dev/apps-xplat/node_modules/electron-builder/node_modules/yargs/yargs.js:1004:21)
    at Object.<anonymous> (/Users/sasha/Dev/apps-xplat/node_modules/electron-builder/src/cli/cli.ts:25:28)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at findNodeScript.then.existing (/Users/sasha/Dev/apps-xplat/node_modules/npx/node_modules/libnpx/index.js:268:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! apps-xplat@0.0.0 postinstall: `ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES=true npx electron-builder install-app-deps`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the apps-xplat@0.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sasha/.npm/_logs/2019-02-20T22_21_46_772Z-debug.log
@NathanWalker
Copy link
Member

I see the same thing just now with node 10.2 as well. Investigating. Likely an electron dep needs updating but we'll see.

@NathanWalker
Copy link
Member

@NathanWalker
Copy link
Member

NathanWalker commented Feb 24, 2019

Ok @ph55 I have a fix for this now and am rolling into an xplat update today which updates all electron dependencies and postinstall. You can simply run ng update @nstudio/schematics now to fix or if you run into trouble with ng update you can make the following manual changes:

Open root package.json and make the following changes:

Add to dependencies

  • "@angular/http": "^7.0.0",

We could keep unresolved dep flag on electron but not worth it so just add this.

Modify devDependencies as follows:

    "electron": "^4.0.5",
    "electron-builder": "^20.38.4",
    "electron-rebuild": "~1.8.4",
    "electron-installer-dmg": "~2.0.0",
    "electron-packager": "~13.1.0",
    "electron-reload": "~1.4.0",
    "electron-store": "~2.0.0",
    "electron-updater": "~4.0.6",

That updates all electron dependencies and importantly adds electron-rebuild.

Modify scripts as follows:

"postinstall": "electron-rebuild install-app-deps",

Now modify your electron app apps/electron-devops/tsconfig.json as follows:

  • Add "types": ["jasmine"], so it should look like this:
{
  "compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "target": "es5",
    "types": ["jasmine"],
    "typeRoots": ["../../node_modules/@types"],
    "lib": ["es2017", "es2016", "es2015", "dom"]
  },
  "include": ["src/index.ts"]
}

That's needed to prevent jest types from colliding with jasmine as mentioned here.

Now clean and reinstall your workspace:

npm cache clean --force   // for good measure!
rm -rf node_modules package-lock.json 
npm i

You should now be able to run all apps including your electron app with:

npm run start.electron.devops

Lemme know if that gets you going and thanks for reporting this 👍

@NathanWalker
Copy link
Member

NathanWalker commented Feb 24, 2019

In 7.3.1 I updated electron to latest v4 and ended up ensuring @angular/http is at least installed to avoid the need of using ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES keeping things simpler.

You can now simply run ng update @nstudio/schematics if using angular cli 7.3.x and above. If using previous angular cli version just note this here if using ng update 👍

@ph55
Copy link
Author

ph55 commented Feb 24, 2019

#84 (comment)

@NathanWalker works well, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants