ElectronでA JavaScript error occurred in the main processが出た。
This article was I postscript in English.(2016/01/21)
Electronを始めたばかりです。
WEB系の技術は読める程度でスラスラ書けるわけではないので、サクっと動作を確認してみたく下記サイトを参考にチュートリアってみました。
Electronでデスクトップウィジェットを作るまで
ところが初っ端から表題のエラーが出ました。
「A JavaScript error occurred in the main process」
少し長くなりそうなので結論
package.jsonの文字コードがANSI以外になっていませんか?私の場合は以前VisualStudioで編集するとUTF-8がANSIに変換されているといった現象にあったことがあり、チュートリアル中にほぼ無意識でメモ帳で開きANSIからUTF-8に保存しなおしていました。
ちなみに2016/01/20現在、Googleで「electron a javascript error occurred in the main process」と検索する下記ページも見てましたが、同じSyntaxErrorでも
SyntaxError: missing ) after argument list
Electronを実行するとdefault_app.jsが動く場合に疑ってみるポイント。
とあり、今回の
「SyntaxError: Unexpected token」
とは違います。
追記 Postscript(2016/01/21)
Google Analyticsを見ると、この記事を投稿して一気にセッションとページビューが上がりました。
特に海外からの訪問が多いようです。
When I look at Google Analytics, it went up at a stretch sessions and page views by posting this article.
In particular, it seems that many visitors from outside Japan.
So I write once in English.
Solution in my case was a character code of package.json.
I've changed the character code of package.js from ANSI to UTF-8. It has caused this error that "SyntaxError: Unexpected token".