Electron Quick Start

Electron is a good choice to build cross platform desktop apps with JavaScript, HTML, and CSS. In this article, I will guide you to install all necessary packages, get electron-quick-start running and create the dist package.


node.js

First, you need install node.js. The v6.9.1 is used in my case.

1
2
$ node --version
v6.9.1

Fetch code

1
git clone https://github.com/electron/electron-quick-start.git

Install packages and run

1
2
3
cd electron-quick-start
npm install
npm start

In China, the installation process may suspend due to the problem of downloading electron binary package (version 1.7.10 in my case), even with taobao registry enabled. One possible workaround is fetching the package directly and put in the cache directory, so the script install.js can uncompress the package without downloading.

1
2
cd ~/.electron
wget https://npm.taobao.org/mirrors/electron/1.7.10/electron-v1.7.10-darwin-x64.zip

Create the dist package

1
electron-packager electron-quick-start/ quick-start

console-logging-in-javascript

Today, I watched the 7 lesson of “Advanced Logging with the JavaScript Console“. My debugging skill with JavaScript console was enhanced a lot.

Log levels

1
2
3
4
5
console.log()
console.warn()
console.error()
console.info()
console.debug()

Log arguments

We can use the similar formatting in printf of C.

1
console.log('Your age is %d', 5)

Grouping and nesting

We group outputs by name.

1
2
console.group("GroupName");
console.groupEnd("GroupName");

Assert

We can make some assertions with function assert. But it does not mean the error is handled.

1
console.assert(info)

Count

We can count outputs with function count.

1
console.count("name")

Timing

1
2
console.time("name");
console.timeEnd("name");

Table

1
console.table(obj)