找不到电子应用 [英] Unable to find electron app

查看:71
本文介绍了找不到电子应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Ubuntu上运行此 youtube教程 17.10以及当我运行build命令 ng build --prod&电子。结果是:

I'm running through this youtube tutorial on an Ubuntu 17.10 and when I run the build command ng build --prod && electron . the result is:

启动应用程序
出错在/ home / ole / angular-electron <找不到电子应用程序

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

找不到模块'/ home / ole / angular-electron'

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

该应用编译正常,只是 electron。步骤失败。包含 main 属性的 package.json 内容如下:

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",

我也尝试过运行命令

    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

也尝试过与 electron。分别运行电子命令。结果是一样的。它抱怨说找不到电子。还尝试从 node_modules 目录运行它,如下所示:

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。
启动应用程序时出错
无法在/ home / ole / angular-electron中找到Electron应用程序

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

找不到模块'/ home / ole / angular -electron'

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

有什么想法?

推荐答案

首先将电子安装为像您对 npm i --save-dev electronic 所做的开发依赖。然后设置您的构建脚本,如下所示:

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 .".

编辑:

我认为应该做的足够:

$ npm run electron

您不必编辑 package.json npm 会尝试在 node_modules / .bin 电子 c>然后它将搜索您的全局依赖项。

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.

尽量避免安装全局 npm 依赖项。如果由于项目需要而正在安装命令行工具,则始终将其安装在本地。

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.

这篇关于找不到电子应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆