index.html ファイルを配信するポート 8080 でローカル サーバーを実行するノード js アプリがあります。ワンクリックで実行するには、ノード js アプリを exe に変換する必要があります。node js アプリをnexe モジュールでexe に変換しようとしましたが、作成された exe が実行されず、クラッシュします。どこが間違っているのか、または他のモジュールで試す必要があるのか わかりません。これについて私を案内してください。必要なファイルと私の試みは次のとおりです。
package.json ファイル
{
"name": "node-web-example",
"version": "1.0.0",
"description": "",
"main": "bundle.js",
"scripts": {
"start": "npm run bundle-js | http-server",
"bundle-js": "watchify main.js -o bundle.js",
"build": "nexe -r bundle.js -r index.html -r style.css -o MyApplication-1.exe -t x86-8.0.0"
},
"author": "",
"license": "ISC",
"dependencies": {
"dotenv": "^8.2.0",
"uneeq-js": "^2.35.0"
},
"devDependencies": {
"browserify": "^16.5.0",
"nexe": "^4.0.0-beta.18",
"watchify": "^3.11.1"
}
}
exeビルドの場合、コマンドを使用してnpm run build
失敗しました
これは、ターミナルから exe を実行したときのエラー トレースです。
var n=V(105),r=V(106),i=V(83);function o(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=a.prototype:(null===e&&(e=new a(t)),e.length=t),e}function a(e,t,V){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(e,t,V);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return h(this,e)}return c(this,e,t,V)}function c(e,t,V,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,V,n){if(t.byteLength,V<0||t.byteLength<V)throw new RangeError("'offset' is out of bounds");if(t.byteLength<V+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===V&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,V):new Uint8Array(t,V,n);
ReferenceError: window is not defined
at Module.n.__awaiter.V (D:\Uneeq Demo\examples\web\node\bundle.js:192:140642)
at V (D:\Uneeq Demo\examples\web\node\bundle.js:170:158)
at Object.e.exports (D:\Uneeq Demo\examples\web\node\bundle.js:185:23055)
at V (D:\Uneeq Demo\examples\web\node\bundle.js:170:158)
at Object.setPrototypeOf.__proto__ (D:\Uneeq Demo\examples\web\node\bundle.js:170:957)
at Object.__dirname.2 (D:\Uneeq Demo\examples\web\node\bundle.js:170:967)
at o (D:\Uneeq Demo\examples\web\node\bundle.js:1:327)
at D:\Uneeq Demo\examples\web\node\bundle.js:1:378
at Object.__dirname.1.uneeq-js (D:\Uneeq Demo\examples\web\node\bundle.js:2:22)
at o (D:\Uneeq Demo\examples\web\node\bundle.js:1:327)
ただしnpm start
、ターミナルで を使用すると、そこから正常に実行され、Web ページは localhost://8080 で開くことができます。
どんな助けや指示も大歓迎です!!