最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Unable to run Electron Quick Start in WSL - Stack Overflow

programmeradmin5浏览0评论

Hi I'm running Ubuntu 16.04.3 LTS on Windows Subsystem Linux. I'm trying to run the Quick Start first app as listed in this section here however, I keep getting the same error no matter if I clone the repository, write it myself, or delete and reinstall the Electron module.

> electron .

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `electron .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

For reference I'm running Node: 9.11.1 NPM: 5.8.0

Hi I'm running Ubuntu 16.04.3 LTS on Windows Subsystem Linux. I'm trying to run the Quick Start first app as listed in this section here https://electronjs/docs/tutorial/first-app however, I keep getting the same error no matter if I clone the repository, write it myself, or delete and reinstall the Electron module.

> electron .

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `electron .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

For reference I'm running Node: 9.11.1 NPM: 5.8.0

Share Improve this question asked Apr 20, 2018 at 8:03 jps_dot_devjps_dot_dev 1152 silver badges14 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 11

Electron needs to open a chrome browser window. So, when you run it from WSL using a node.js that was installed in WSL, I guess it would try to start the chromium browser for Ubuntu, which will not work out of the box, because:

Microsoft doesn't support graphical programs on WSL. Bash on WSL is intended for running mand-line programs that developers might need, but it's possible to run graphical Linux desktop programs on Windows using the Bash shell. To be more precise, you'll be able to display graphical programs running in WSL on a Windows 10 desktop by using an X server which runs on Windows 10.

https://virtualizationreview./articles/2017/02/08/graphical-programs-on-windows-subsystem-on-linux.aspx

I found the easiest way is to install electron on Windows then start it from WSL.

Steps:

Make sure you have Node.js & npm installed on your Windows machine (you can remove them afterwards) Open cmd.exe, move to your project directory and run npm install electron --save-dev.

This will install the Windows version of the prebuilt Electron binary instead of the Linux one, which would occur if you try to install from WSL. (This is the actual trick) Enter Bash on Ubuntu on Windows, move to your project directory then run ./node_modules/.bin/electron (or use an npm script) to launch your Electron app Though, I'm not sure this is very convenient, it seems to work well.

I hope this will help people encoutering the same issue in the future!

Ref: https://github./electron-userland/electron-prebuilt/issues/260

run a X-server app in windows, then export DISPLAY , run the npm start.

发布评论

评论列表(0)

  1. 暂无评论