質問編集履歴

2

修正

2019/09/01 13:43

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,133 +1,15 @@
1
- expressローカルサーバで動作していたものをelectronでEXE化したいと思い
1
+ electronのelectron-packagerでEXE化したのですが
2
2
 
3
+ 出力されたアプリのフォルダ内にnode_moduleフォルダが存在しないのですが、
4
+
3
- EXEたのですがelectron cannot find module expressとエラーになってしまいました
5
+ 存在ないと、csv モジュールがありませんとエラーになってしまいま
4
6
 
5
7
 
6
8
 
7
- Electeonをコマンドから実行した場合は、実行できていました。
8
-
9
- expressはローカルでインストされており。jsonファイルにも名前が書かれています。
9
+ でも入門講座での説明通りに進めると、node_moduleフォダが存在しない状態パッケジ化されています。
10
10
 
11
11
 
12
12
 
13
+ csvモジュールは入門講座とは違いコマンドで自分で追加したものです。
13
14
 
14
-
15
- ```Javascript
16
-
17
- //main.js
18
-
19
-
20
-
21
- // Server Start
22
-
23
- const expressApp = require('./server.js')
24
-
25
- expressApp.listen(3000, '127.0.0.1')
26
-
27
-
28
-
29
- const { app, BrowserWindow } = require("electron");
30
-
31
-
32
-
33
- function createWindow() {
34
-
35
- // メインウィンドウ作成
36
-
37
- mainWindow = new BrowserWindow({
38
-
39
- width: 400,
40
-
41
- height: 500
42
-
43
- });
44
-
45
-
46
-
47
- // メインウィンドウに表示するURLを指定
48
-
49
- mainWindow.loadURL('http://127.0.0.1:3000')
50
-
51
-
52
-
53
- mainWindow.on("closed", () => {
54
-
55
- mainWindow = null;
56
-
57
- });
58
-
59
- }
60
-
61
-
62
-
63
- app.on("ready", createWindow);
64
-
65
-
66
-
67
- app.on("window-all-closed", () => {
68
-
69
- if (process.platform !== "darwin") {
70
-
71
- app.quit();
72
-
73
- }
74
-
75
- });
76
-
77
-
78
-
79
- app.on("activate", () => {
80
-
81
- if (mainWindow === null) {
82
-
83
- createWindow();
84
-
85
- }
86
-
87
- });
88
-
89
- ```
90
-
91
-
92
-
93
- ``` Javascript
94
-
95
- //server.js
96
-
97
-
98
-
99
- let express = require('express');
100
-
101
- let path = require('path');
102
-
103
-
104
-
105
- let app = express();
106
-
107
-
108
-
109
- app.use(express.json());
110
-
111
- app.use(express.urlencoded({ extended: false }));
112
-
113
- app.use(express.static(path.join(__dirname, 'public')));
114
-
115
-
116
-
117
- let listener = app.listen(3000, function() {
118
-
119
- console.log(listener.address().port);
15
+ パッケージ化はnode_moduleフォルダを含めるのが正しいのでしょうか?
120
-
121
- });
122
-
123
-
124
-
125
- app.get('/', function (req, res) {
126
-
127
- res.sendFile(__dirname + '/views/index.html');
128
-
129
- })
130
-
131
- module.exports = app;
132
-
133
- ```

1

修正

2019/09/01 13:43

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -26,8 +26,6 @@
26
26
 
27
27
 
28
28
 
29
- // Electronのモジュール
30
-
31
29
  const { app, BrowserWindow } = require("electron");
32
30
 
33
31
 
@@ -38,31 +36,19 @@
38
36
 
39
37
  mainWindow = new BrowserWindow({
40
38
 
41
- width: 800,
39
+ width: 400,
42
40
 
43
- height: 600,
41
+ height: 500
44
-
45
- //autoHideMenuBar: true // メニューバーを隠す
46
42
 
47
43
  });
48
44
 
49
45
 
50
46
 
51
- // メインウィンドウに表示するURLを指定します
47
+ // メインウィンドウに表示するURLを指定
52
-
53
- //mainWindow.loadFile('views/index.html');
54
48
 
55
49
  mainWindow.loadURL('http://127.0.0.1:3000')
56
50
 
57
51
 
58
-
59
- // デベロッパーツールの起動
60
-
61
- mainWindow.webContents.openDevTools();
62
-
63
-
64
-
65
- // メインウィンドウクローズ時
66
52
 
67
53
  mainWindow.on("closed", () => {
68
54
 
@@ -74,17 +60,11 @@
74
60
 
75
61
 
76
62
 
77
- // 初期化完了時の処理
78
-
79
63
  app.on("ready", createWindow);
80
64
 
81
65
 
82
66
 
83
- // 全てのウィンドウが閉じたときの処理
84
-
85
67
  app.on("window-all-closed", () => {
86
-
87
- // macOSのとき以外はアプリケーションを終了させます
88
68
 
89
69
  if (process.platform !== "darwin") {
90
70
 
@@ -96,11 +76,7 @@
96
76
 
97
77
 
98
78
 
99
- // アプリケーションがアクティブになった時の処理
100
-
101
79
  app.on("activate", () => {
102
-
103
- // メインウィンドウが消えている場合は再度メインウィンドウを作成する
104
80
 
105
81
  if (mainWindow === null) {
106
82