electron-packagerのエラー解決

electron製のエスペラント日本語辞書アプリlina_dictoについて、パッケージ作成時のエラーを解決した際のメモ。



electron-packagerで下記エラーが出て、 node_modules再インストール等でも治らなかったので対処。

#  npm-check-updates によると思われるエラー
 
```

MN@daisy-bell:lina_dicto/$ npm install electron-packager --save-dev
npm ERR! path /home/HOME/lina_dicto/lina_dicto/node_modules/npm-check-updates/node_modules/npm/node_modules/dezalgo
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/home/HOME/lina_dicto/lina_dicto/node_modules/npm-check-updates/node_modules/npm/node_modules/dezalgo' -> '/home/HOME/lina_dicto/lina_dicto/node_modules/npm-check-updates/node_modules/npm/node_modules/.dezalgo.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/HOME/.npm/_logs/2017-12-21T12_10_15_965Z-debug.log


```

npm-check-updatesが競合か何かで悪さをしていた模様。
下記の通り依存パッケージから消して、node_modulesとpackage-lock.jsonを削除してから再インストールで解決。

```

MN@daisy-bell:lina_dicto/$ git diff
diff --git a/lina_dicto/package.json b/lina_dicto/package.json
index 200d447..387b961 100644
--- a/lina_dicto/package.json
+++ b/lina_dicto/package.json
@@ -22,13 +22,12 @@
     "babel-register": "^6.26.0",
     "electron": "^1.8.1",
     "electron-installer-debian": "^0.7.1",
-    "electron-packager": "10.1.0",
+    "electron-packager": "^10.1.0",
     "intelli-espower-loader": "^1.0.1",
     "mocha": "^4.0.1",
     "power-assert": "^1.4.4"
   },
   "dependencies": {
-    "npm": "^5.6.0",
-    "npm-check-updates": "^2.13.0"
+    "npm": "^5.6.0"
   }
 }

```









# ignore設定によると思われるエラー




下記のようなエラーが出た。

```
npm ERR! path /tmp/electron-packager/darwin-x64/lina_dicto-darwin-x64/Electron.app/Contents/Resources/app/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/object-assign
```


```
MN@daisy-bell:lina_dicto/$ bash ./installer_darwin.sh
~/lina_dicto/lina_dicto ~/lina_dicto
Packaging app for platform darwin x64 using electron v1.8.1
/home/HOME/lina_dicto/lina_dicto/build_darwin.js:19
                throw new Error(err);
                ^

Error: Error: Command failed: npm prune --production
npm ERR! path /tmp/electron-packager/darwin-x64/lina_dicto-darwin-x64/Electron.app/Contents/Resources/app/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/object-assign
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/tmp/electron-packager/darwin-x64/lina_dicto-darwin-x64/Electron.app/Contents/Resources/app/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/object-assign' -> '/tmp/electron-packager/darwin-x64/lina_dicto-darwin-x64/Electron.app/Contents/Resources/app/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/.object-assign.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/HOME/.npm/_logs/2017-12-21T12_29_30_221Z-debug.log

    at done (/home/HOME/lina_dicto/lina_dicto/build_darwin.js:19:11)
    at Immediate._onImmediate (/home/HOME/lina_dicto/lina_dicto/node_modules/nodeify/index.js:19:9)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)
error:./installer_darwin.sh(41) "node build_darwin.js" ""

```

設定のignoreから、objectを除くと解決した。

また、下記のようなエラーも出たので、さらにignoreを書き換えて解決した。

```
MN@daisy-bell:lina_dicto/$ bash ./installer_darwin.sh
~/lina_dicto/lina_dicto ~/lina_dicto
Packaging app for platform darwin x64 using electron v1.8.1
/home/HOME/lina_dicto/lina_dicto/build_darwin.js:19
                throw new Error(err);
                ^

Error: Error: Command failed: npm prune --production
npm ERR! path /tmp/electron-packager/darwin-x64/lina_dicto-darwin-x64/Electron.app/Contents/Resources/app/node_modules/npm/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/node_modules/create-error-class/node_modules/capture-stack-trace
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/tmp/electron-packager/darwin-x64/lina_dicto-darwin-x64/Electron.app/Contents/Resources/app/node_modules/npm/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/node_modules/create-error-class/node_modules/capture-stack-trace' -> '/tmp/electron-packager/darwin-x64/lina_dicto-darwin-x64/Electron.app/Contents/Resources/app/node_modules/npm/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/node_modules/create-error-class/node_modules/.capture-stack-trace.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/HOME/.npm/_logs/2017-12-21T12_41_05_486Z-debug.log

    at done (/home/HOME/lina_dicto/lina_dicto/build_darwin.js:19:11)
    at Immediate._onImmediate (/home/HOME/lina_dicto/lina_dicto/node_modules/nodeify/index.js:19:9)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)
error:./installer_darwin.sh(41) "node build_darwin.js" ""

```

最終的に、package設定のファイルを以下のとおりに変更して解決した。
```
 diff --git a/lina_dicto/build_default.js b/lina_dicto/build_default.js
index 86dc120..4a7a678 100644
--- a/lina_dicto/build_default.js
+++ b/lina_dicto/build_default.js
@@ -20,7 +20,7 @@ module.exports =
        ignore: "node_modules/(electron-packager|electron-prebuilt|\\.bin)"
                + "|node_modules/(babel.*|intelli-espower-loader|power-assert.*|mocha)"
                + "|.*\\.txt"
-               + "|work|object|test"
+               + "|work/.*|test/.*"
                + "|data/.*\\.(zip|sh)"
                + "|release\\.js",
        'version-string': {

```

objectを除いておきたかったのだけれど、大きな実害はないのでとりあえずOK。

以上。

electronアプリをbrowserifyしてAndroid移植したmemo

現実世界のelectronでnodejsな趣味コードをbrowserifyした際の知見。 ==== 世の中のまともなプロjsエンジニアは最初からボイラープレートでgulpなビルドパイプラインを構築してまっさらなプロジェクトにjsxコードをおもむろに書き始めるとかしているのだと思い...