70295

Unable to find electron app

Question:

I'm running through this <a href="https://www.youtube.com/watch?v=u_vMChpZMCk&t=6s" rel="nofollow">youtube tutorial</a> on an Ubuntu 17.10 and when I run the build command ng build --prod && electron . the result is:

Error launching app Unable to find Electron app at /home/ole/angular-electron

Cannot find module '/home/ole/angular-electron'

The app compiles fine, just the electron . step that is failing. The package.json contents including the main attribute look like this:

"name": "angular-electron", "version": "0.0.0", "license": "MIT", "main": "main.js",

I also tried running running the command as indicated in the first answer and this is the result:

ole@mki:~/angular-electron$ ng build --prod && npm run electron Date: 2018-02-03T02:57:31.154Z Hash: a2a64f9c18abdabf8e6e Time: 25113ms chunk {0} polyfills.f20484b2fa4642e0dca8.bundle.js (polyfills) 59.4 kB [initial] [rendered] chunk {1} main.34c2037568943aee5abc.bundle.js (main) 152 kB [initial] [rendered] chunk {2} styles.9c0ad738f18adc3d19ed.bundle.css (styles) 79 bytes [initial] [rendered] chunk {3} inline.ef66fc99c35b976a47ae.bundle.js (inline) 1.45 kB [entry] [rendered] > angular-electron@0.0.0 electron /home/ole/Junk/angular-electron > electron . Error launching app Unable to find Electron app at /home/ole/Junk/angular-electron Cannot find module '/home/ole/Junk/angular-electron' npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! angular-electron@0.0.0 electron: `electron .` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the angular-electron@0.0.0 electron 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! /home/ole/.npm/_logs/2018-02-03T02_57_32_025Z-debug.log ole@mki:~/Junk/angular-electron$ ng build --prod && npm run electron Date: 2018-02-03T02:59:37.741Z Hash: a2a64f9c18abdabf8e6e Time: 25083ms chunk {0} polyfills.f20484b2fa4642e0dca8.bundle.js (polyfills) 59.4 kB [initial] [rendered] chunk {1} main.34c2037568943aee5abc.bundle.js (main) 152 kB [initial] [rendered] chunk {2} styles.9c0ad738f18adc3d19ed.bundle.css (styles) 79 bytes [initial] [rendered] chunk {3} inline.ef66fc99c35b976a47ae.bundle.js (inline) 1.45 kB [entry] [rendered] > angular-electron@0.0.0 electron /home/ole/Junk/angular-electron > electron . Error launching app Unable to find Electron app at /home/ole/Junk/angular-electron Cannot find module '/home/ole/Junk/angular-electron' npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! angular-electron@0.0.0 electron: `electron .` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the angular-electron@0.0.0 electron 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! /home/ole/.npm/_logs/2018-02-03T02_59_38_568Z-debug.log ole@mki:~/Junk/angular-electron$ ng build --prod && npm run electron . Date: 2018-02-03T03:01:35.087Z Hash: a2a64f9c18abdabf8e6e Time: 25017ms chunk {0} polyfills.f20484b2fa4642e0dca8.bundle.js (polyfills) 59.4 kB [initial] [rendered] chunk {1} main.34c2037568943aee5abc.bundle.js (main) 152 kB [initial] [rendered] chunk {2} styles.9c0ad738f18adc3d19ed.bundle.css (styles) 79 bytes [initial] [rendered] chunk {3} inline.ef66fc99c35b976a47ae.bundle.js (inline) 1.45 kB [entry] [rendered] > angular-electron@0.0.0 electron /home/ole/Junk/angular-electron > electron . "." Error launching app Unable to find Electron app at /home/ole/Junk/angular-electron Cannot find module '/home/ole/Junk/angular-electron' npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! angular-electron@0.0.0 electron: `electron . "."` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the angular-electron@0.0.0 electron 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! /home/ole/.npm/_logs/2018-02-03T03_01_35_948Z-debug.log

Also tried running the electron command separately with electron .. The result is the same. It complains that it can't find electron. Also tried running it from the node_modules directory like this:

ole@mki:~/angular-electron$ ./node_modules/electron/dist/electron . Error launching app Unable to find Electron app at /home/ole/angular-electron

Cannot find module '/home/ole/angular-electron'

Thoughts?

Answer1:

First install electron as a dev dependency like you have done with npm i --save-dev electron. Then setup your build scripts like this:

"electron": "electron", "electron-build": "ng build --prod && npm run electron"

The reason electron was not running is that it included a . in the electron run script like this `"electron": "electron .".

<strong>EDIT:</strong>

I believe it should be enough to do:

$ npm run electron

You don't have to edit your package.json. npm will try to find the electron in your node_modules/.bin then it will search in your global dependencies.

Try to avoid installing global npm dependencies. If you are installing a command line tool because your project needs it then always install it locally.

Answer2:

If you are using @angular/cli ~1.4.0, make sure main.js and package.json are in same folder.

<root>/src index.html main.ts main.js package.json

Recommend

  • Check if date isDSTShifted
  • How to update the document on solr 6.0?
  • How to replace in values in spark dataframes after recalculations?
  • Calculating number of occurrences of dual parameter match in a csv appending the results to csv
  • Different outcomes when using tf.Variable() and tf.get_variable()
  • Increasing dimensions on hover without changing the position of other elements
  • How to calculate % difference of row items in Julia array succinctly
  • Use pnorm from Rmath.h with Rcpp
  • ExtensionDataObject not marked as serializable
  • Is it possible to extract the value from processing-instruction ('define') with XPath?
  • Mongo server accepts credentials from shell, but not from Java/Scala interface
  • Solid Shadow in All Directions
  • How to achieve indepedent multi module versioning with sbt-release plugin
  • Invoke another constructor in the same class
  • How to search for a record and then delete it
  • npm thinks node is out of date, but it isn't
  • Why can't python-colormath convert sRGB to Adobe RGB?
  • Collect HostCPU utilisation and disk I/O speed using XenServer Java API
  • bcrypt-nodejs compare method returns false every time
  • Fortran 90 function return pointer
  • Grunt watch Running “watch” task Waiting
  • Why I can't use uniform1f instead of uniform4f for setting a vec4 uniform?
  • Stitching 2 images (OpenCV)
  • Cordova Apache wrong module path
  • How to resolve this packager error on react native Android
  • Installing PHP 7 on digitalocean
  • How to generate and display a QR Code in ionic 2
  • Problems installing Yesod for Haskell
  • Rails Find when some params will be blank
  • Mysterious problem with floating point in LISP - time axis generation
  • Illegal mix of collations for operation for date/time comparison
  • Release, debug version and Authorization Google?
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • How to include full .NET prerequisite for Wix Burn installer
  • Hits per day in Google Big Query
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • costura.fody for a dll that references another dll
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize