Ole*_*Ole 0 javascript electron angular
我正在Ubuntu 17.10上运行此youtube教程,当我运行build命令时ng build --prod && electron .,结果是:
启动应用程序时出错,无法在/ home / ole / angular-electron中找到Electron应用程序
找不到模块'/ home / ole / angular-electron'
该应用程序编译正常,只是electron .失败的一步。package.json包含main属性的内容如下所示:
"name": "angular-electron",
"version": "0.0.0",
"license": "MIT",
"main": "main.js",
Run Code Online (Sandbox Code Playgroud)
我还尝试按照第一个答案中的指示运行命令,结果如下:
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
Run Code Online (Sandbox Code Playgroud)
还尝试了与分别运行电子命令electron .。结果是一样的。它抱怨找不到electron。还尝试从这样的node_modules目录运行它:
ole @ mki:〜/ angular-electron $ ./node_modules/electron/dist/electron。启动应用程序时出错,无法在/ home / ole / angular-electron中找到Electron应用程序
找不到模块'/ home / ole / angular-electron'
有什么想法吗?
首先将电子安装为dev依赖项,就像您使用过的那样npm i --save-dev electron。然后像这样设置您的构建脚本:
"electron": "electron",
"electron-build": "ng build --prod && npm run electron"
Run Code Online (Sandbox Code Playgroud)
电子不运行的原因是,它.在电子运行脚本中包含类似“电子”的电子:“电子”。
编辑:
我相信这样做应该足够了:
$ npm run electron
Run Code Online (Sandbox Code Playgroud)
您无需修改package.json。npm将尝试在中找到electron,node_modules/.bin然后在全局依赖项中进行搜索。
尝试避免安装全局npm依赖项。如果由于项目需要而要安装命令行工具,则始终将其安装在本地。
| 归档时间: |
|
| 查看次数: |
5427 次 |
| 最近记录: |