質問編集履歴

1

誤字修正

2021/09/30 13:22

投稿

iwanao513
iwanao513

スコア1

test CHANGED
File without changes
test CHANGED
@@ -1,10 +1,6 @@
1
1
  Vue+Electronでアプリ開発を行っています。
2
2
 
3
- ファイルの出力を行いたく、require("fs")で呼び出してfs.writeFileをやろうとしたところ
4
-
5
- 「fs.writeFile is not a function」
6
-
7
- のエラーが出ています。
3
+ ファイル出力を行いたくコードを書いたところ、エラーが出ています。
8
4
 
9
5
 
10
6
 
@@ -12,4 +8,128 @@
12
8
 
13
9
 
14
10
 
15
- 試したこと
11
+
12
+
13
+ ### 発生している問題・エラーメッセージ
14
+
15
+
16
+
17
+ ```
18
+
19
+ 「fs.writeFile is not a function」
20
+
21
+ ```
22
+
23
+
24
+
25
+ ### 該当のソースコード
26
+
27
+
28
+
29
+ ```JS
30
+
31
+ <template>
32
+
33
+ <div class="header">
34
+
35
+ <button type="button" v-on:click="filemake">ファイル作成</button>
36
+
37
+
38
+
39
+ </div>
40
+
41
+
42
+
43
+ </template>
44
+
45
+
46
+
47
+ <script>
48
+
49
+
50
+
51
+ const fs = require('fs');
52
+
53
+ export default {
54
+
55
+ name: 'Home',
56
+
57
+ components: {
58
+
59
+
60
+
61
+ },
62
+
63
+ data() {
64
+
65
+ return {
66
+
67
+
68
+
69
+ }
70
+
71
+ },
72
+
73
+ computed:{
74
+
75
+
76
+
77
+ },
78
+
79
+ methods: {
80
+
81
+
82
+
83
+ filemake(){
84
+
85
+ let text = "テスト出力";
86
+
87
+
88
+
89
+ fs.writeFileSync('out.txt', text, (err) => {
90
+
91
+ if(err) console.log(err);
92
+
93
+ else console.log('write end');
94
+
95
+ });
96
+
97
+
98
+
99
+
100
+
101
+ }
102
+
103
+ }
104
+
105
+ }
106
+
107
+ </script>
108
+
109
+ ```
110
+
111
+
112
+
113
+ ### 試したこと
114
+
115
+ ルートディレクトリにvue.config.jsを追加
116
+
117
+ [参考ページ](https://www.waguri-soft.com/2020/10/12/vue3-0-electron%E3%81%A7%E3%83%A1%E3%83%A2%E5%B8%B3%E3%83%87%E3%82%B9%E3%82%AF%E3%83%88%E3%83%83%E3%83%97%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92%E4%BD%9C%E3%82%8B/)
118
+
119
+ ```JS
120
+
121
+ module.exports = {
122
+
123
+ pluginOptions: {
124
+
125
+ electronBuilder: {
126
+
127
+ nodeIntegration: true
128
+
129
+ }
130
+
131
+ }
132
+
133
+ }
134
+
135
+ ```