{"id":201,"date":"2020-07-14T20:00:56","date_gmt":"2020-07-14T11:00:56","guid":{"rendered":"http:\/\/drroot.page\/wp\/?p=201"},"modified":"2020-10-15T09:25:46","modified_gmt":"2020-10-15T00:25:46","slug":"electron%e3%81%a7serialport%e3%82%92%e4%bd%bf%e3%81%8a%e3%81%86%e3%81%a8%e3%81%99%e3%82%8b%e3%81%a8%e3%81%82%e3%82%8c%e3%81%93%e3%82%8c%e3%82%a8%e3%83%a9%e3%83%bc","status":"publish","type":"post","link":"https:\/\/drroot.page\/wp\/?p=201","title":{"rendered":"Electron\u3067serialport\u3092\u4f7f\u304a\u3046\u3068\u3059\u308b\u3068\u3042\u308c\u3053\u308c\u30a8\u30e9\u30fc"},"content":{"rendered":"<pre><code>App threw an error during load\nTypeError: Cannot read property &#039;indexOf&#039; of undefined\n    at Function.getFileName (webpack:\/\/\/.\/node_modules\/bindings\/bindings.js?:178:16)\n    at bindings (webpack:\/\/\/.\/node_modules\/bindings\/bindings.js?:82:48)\n    at eval (webpack:\/\/\/.\/node_modules\/@serialport\/bindings\/lib\/win32.js?:1:91)\n    at Object..\/node_modules\/@serialport\/bindings\/lib\/win32.js (path\\to\\your\\project\\dist_electron\\index.js:261:1)\n    at __webpack_require__ (path\\to\\your\\project\\dist_electron\\index.js:20:30)\n    at eval (webpack:\/\/\/.\/node_modules\/@serialport\/bindings\/lib\/index.js?:6:22)\n    at Object..\/node_modules\/@serialport\/bindings\/lib\/index.js (path\\to\\your\\project\\dist_electron\\index.js:173:1)\n    at __webpack_require__ (path\\to\\your\\project\\dist_electron\\index.js:20:30)\n    at eval (webpack:\/\/\/.\/node_modules\/serialport\/lib\/index.js?:2:17)\n    at Object..\/node_modules\/serialport\/lib\/index.js (path\\to\\your\\project\\dist_electron\\index.js:1517:1)<\/code><\/pre>\n<p>\u74b0\u5883\u306fwindows8.1\u3001electron\u304c9.0.0\u3001serialport\u30829.0.0\u3002<br \/>\n\u5b9f\u884c\u6642\u306b\u4e0a\u8a18\u30a8\u30e9\u30fc\u3002\u3060\u3044\u3076\u30cf\u30de\u3063\u305f\u306e\u3067\u89e3\u6c7a\u7b56\u3092\u6b8b\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<h1>\u30cf\u30de\u308a\u30dd\u30a4\u30f3\u30c8<\/h1>\n<p>serialport\u306f\u30cd\u30a4\u30c6\u30a3\u30d6\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u547c\u3070\u308c\u308b\u3082\u306e\u3067\u3001electron\u304b\u3089\u53e9\u304f\u306b\u306f\u3072\u3068\u624b\u9593\u8ffd\u52a0\u304c\u3044\u308b\u3002<br \/>\nnpm i serialport\u3057\u305f\u3060\u3051\u3058\u3083\u4e0a\u624b\u304f\u52d5\u304b\u306a\u3044\u308f\u3051\u3060\u3002<\/p>\n<p>\u30cd\u30a4\u30c6\u30a3\u30d6\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u8d70\u3089\u305b\u65b9\u306fElectron\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u304c\u3042\u308a\u3001<br \/>\n<a href=\"https:\/\/www.electronjs.org\/docs\/tutorial\/using-native-node-modules\">https:\/\/www.electronjs.org\/docs\/tutorial\/using-native-node-modules<\/a><\/p>\n<p>\u307e\u305fserialport\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u3082Electron\u5411\u3051\u306e\u5c0e\u5165\u65b9\u6cd5\u304c\u66f8\u3044\u3066\u3042\u308b\u3002<br \/>\n<a href=\"https:\/\/serialport.io\/docs\/guide-installation\">https:\/\/serialport.io\/docs\/guide-installation<\/a><\/p>\n<p>\u3056\u3063\u304f\u308a\u624b\u9806\u3092\u307e\u3068\u3081\u308b\u3068\u3001<\/p>\n<ul>\n<li>npm i serialport\u3067\u666e\u901a\u306b\u5c0e\u5165<\/li>\n<li>npm i <strong>&#8211;save-dev<\/strong> electron-rebuild \u3067\u30ea\u30d3\u30eb\u30c9\u30c4\u30fc\u30eb\u5c0e\u5165<\/li>\n<li>package.json\u306escripts\u6b04\u306b &quot;rebuild&quot;: &quot;electron-rebuild -f -w serialport&quot; \u8ffd\u52a0<\/li>\n<li>npm run rebuild \u5b9f\u884c(\u76f4\u63a5\u30b3\u30de\u30f3\u30c9\u53e9\u3044\u3066\u3082\u3044\u3044\u306f\u305a)<\/li>\n<\/ul>\n<p>\u3061\u306a\u307f\u306belectron-rebuild\u306f\u5fc5\u305adevelopment\u9818\u57df\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3002<br \/>\n\u307e\u3041\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u8aad\u3093\u3067\u305d\u306e\u3068\u304a\u308a\u306b\u3084\u308c\u3070OK\u3060\u3002<\/p>\n<p>\u3053\u308c\u3067\u4e0a\u624b\u304f\u3044\u304f\u3068\u5ba3\u3046\u8a18\u4e8b\u304c\u591a\u3044\u3093\u3060\u304c\u3001rebuild\u304c\u4f55\u3082\u305b\u305a\u6210\u529f\uff01\uff57\u3068\u8a00\u3044\u5f35\u308b\u4e00\u65b9\u5168\u304f\u52d5\u3044\u3066\u304f\u308c\u306a\u3044\u3002<\/p>\n<h2>rebuild\u901a\u3059\u307e\u3067<\/h2>\n<p>\u307e\u305a\u3001serialport\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u3082\u66f8\u3044\u3066\u3042\u308b\u304c\u3001Windows\u306e\u30ea\u30d3\u30eb\u30c9\u51e6\u7406\u306b\u306f\u4e88\u3081\u5165\u308c\u3066\u304a\u304f\u3079\u304d\u30c4\u30fc\u30eb\u7fa4\u304c\u3042\u308b\u3002<br \/>\n\u3082\u3057\u4e0b\u8a18\u306e\u5c0e\u5165\u304c\u307e\u3060\u306a\u3089\u3084\u3063\u3066\u304a\u304b\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3002<\/p>\n<ul>\n<li>\u9069\u5f53\u306bPython\u5165\u308c\u308b \u53ef\u80fd\u306a\u30892\u7cfb\u304c\u3044\u3044\u3089\u3057\u3044\u3051\u3069\u3044\u3044\u52a0\u6e1b\u3084\u3081\u3066\u307b\u3057\u3044\u3088\u306d\u2026<\/li>\n<li>npm install &#8211;global &#8211;production windows-build-tools \u3092<strong>\u7ba1\u7406\u8005\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089<\/strong>\u53e9\u304f<\/li>\n<\/ul>\n<p>\u3053\u308c\u3067\u30ea\u30d3\u30eb\u30c9\u53e9\u3044\u305f\u3089\u3001<\/p>\n<pre><code>npm ERR! code ELIFECYCLE\nnpm ERR! errno 4294967295\nnpm ERR! yourprojectname rebuild: `electron-rebuild -f -w serialport`\nnpm ERR! Exit status 4294967295\nnpm ERR!\nnpm ERR! Failed at the yourprojectname rebuild script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     C:\\Users\\[yourname]\\AppData\\Roaming\\npm-cache\\_logs\\[date~~]-debug.log<\/code><\/pre>\n<p>\u3046\u30fc\u3093\u3053\u306e\u3002<br \/>\n\u3053\u308c\u304c\u306a\u3063\u304b\u306a\u304b\u89e3\u6c7a\u3057\u306a\u304f\u3066\u3001\u7d50\u5c40VSCode\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3058\u3083\u306a\u304f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30d5\u30a9\u30eb\u30c0\u3067\u65b0\u898f\u306b\u30b3\u30f3\u30bd\u30fc\u30eb\u8d77\u52d5\u3057\u3066\u30b9\u30af\u30ea\u30d7\u30c8\u53e9\u3044\u305f\u3089\u901a\u3063\u305f\u3002<br \/>\n\u308f\u3063\u3051\u308f\u304b\u3093\u306d\u3047\u3002<\/p>\n<h2>exclude\u306b\u6307\u5b9a\u3059\u308b<\/h2>\n<p>\u3053\u308c\u3060\u3051\u3067\u3082\u30c0\u30e1\u306a\u30b1\u30fc\u30b9\u304c\u3042\u308b\u3002<br \/>\nSerialport\u3092\u30e1\u30a4\u30f3\u30d7\u30ed\u30bb\u30b9\u3068\u30ec\u30f3\u30c0\u30e9\u30d7\u30ed\u30bb\u30b9\u306e\u3069\u3063\u3061\u304b\u3089\u547c\u3093\u3067\u308b\u304b\u3067\u5909\u308f\u3063\u3066\u304f\u308b\u3093\u3060\u304c\u3001<br \/>\n\u57fa\u672c\u7684\u306b\u30cd\u30a4\u30c6\u30a3\u30d6\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u30d0\u30f3\u30c9\u30eb\u3057\u3061\u3083\u3044\u3051\u306a\u3044\u3002<br \/>\n\u305d\u3053\u3067\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306bvue.config.js\u3092\u4f5c\u6210\uff08TS\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u3082\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u554f\u984c\u7121\u3044\uff09\u3057\u3001<br \/>\n\u4e0b\u8a18\u306e\u3088\u3046\u306a\u8a2d\u5b9a\u3092\u66f8\u304f\u3002<\/p>\n<pre><code class=\"language-javascript\">\/\/ vue.config.js\nmodule.exports = {\n    pluginOptions: {\n        electronBuilder: {\n            externals: [&#039;serialport&#039;]\n        }\n    }\n}<\/code><\/pre>\n<p>\u3053\u308c\u3067\u7d50\u5c40\u52d5\u3044\u305f\u3002\u6b7b\u306c\u307b\u3069\u30c9\u30cf\u30de\u30ea\u3057\u305f\u2026\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>App threw an error during load TypeError &hellip; <a href=\"https:\/\/drroot.page\/wp\/?p=201\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-201","post","type-post","status-publish","format-standard","hentry","category-it"],"_links":{"self":[{"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=\/wp\/v2\/posts\/201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201"}],"version-history":[{"count":0,"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions"}],"wp:attachment":[{"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/drroot.page\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}