質問編集履歴
4
書式改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -296,7 +296,7 @@
|
|
296
296
|
|
297
297
|
}
|
298
298
|
|
299
|
-
``
|
299
|
+
```
|
300
300
|
|
301
301
|
|
302
302
|
|
3
より詳細なソースの共有
test
CHANGED
File without changes
|
test
CHANGED
@@ -251,3 +251,179 @@
|
|
251
251
|
## 追記
|
252
252
|
|
253
253
|
どうやらnuxt.config.tsに問題がありそうです。
|
254
|
+
|
255
|
+
backpack-core経由で起動しているのですが、
|
256
|
+
|
257
|
+
その際にnuxt.config.tsの読み込みに失敗してるみたいです。
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
backpack.config.js
|
262
|
+
|
263
|
+
```js
|
264
|
+
|
265
|
+
module.exports = {
|
266
|
+
|
267
|
+
webpack: (config) => {
|
268
|
+
|
269
|
+
config.entry.main = [
|
270
|
+
|
271
|
+
'./server/index.ts'
|
272
|
+
|
273
|
+
]
|
274
|
+
|
275
|
+
config.resolve = {
|
276
|
+
|
277
|
+
extensions: ['.ts', '.js', '.json']
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
config.module.rules.push(
|
282
|
+
|
283
|
+
{
|
284
|
+
|
285
|
+
test: /.ts$/,
|
286
|
+
|
287
|
+
loader: 'awesome-typescript-loader'
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
)
|
292
|
+
|
293
|
+
return config
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
}
|
298
|
+
|
299
|
+
``
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
/server/index.ts
|
304
|
+
|
305
|
+
```ts
|
306
|
+
|
307
|
+
import express from 'express'
|
308
|
+
|
309
|
+
import consola from 'consola'
|
310
|
+
|
311
|
+
import { Nuxt, Builder } from 'nuxt'
|
312
|
+
|
313
|
+
import bodyParser from 'body-parser'
|
314
|
+
|
315
|
+
import session from 'express-session'
|
316
|
+
|
317
|
+
import cookieParser from 'cookie-parser'
|
318
|
+
|
319
|
+
import csrf from 'csurf'
|
320
|
+
|
321
|
+
import api from './api'
|
322
|
+
|
323
|
+
const app = express()
|
324
|
+
|
325
|
+
app.use(bodyParser.json())
|
326
|
+
|
327
|
+
app.use(bodyParser.urlencoded({
|
328
|
+
|
329
|
+
extended: true
|
330
|
+
|
331
|
+
}))
|
332
|
+
|
333
|
+
app.use(cookieParser())
|
334
|
+
|
335
|
+
app.use(session({
|
336
|
+
|
337
|
+
secret: 'example',
|
338
|
+
|
339
|
+
resave: false,
|
340
|
+
|
341
|
+
saveUninitialized: false,
|
342
|
+
|
343
|
+
cookie: {
|
344
|
+
|
345
|
+
maxage: 1000 * 60 * 30
|
346
|
+
|
347
|
+
}
|
348
|
+
|
349
|
+
}))
|
350
|
+
|
351
|
+
app.use(csrf({
|
352
|
+
|
353
|
+
cookie: true
|
354
|
+
|
355
|
+
}))
|
356
|
+
|
357
|
+
app.use('/api', api)
|
358
|
+
|
359
|
+
// Import and Set Nuxt.js options
|
360
|
+
|
361
|
+
const config = require('../nuxt.config.ts')
|
362
|
+
|
363
|
+
config.dev = !(process.env.NODE_ENV === 'production')
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
async function start() {
|
368
|
+
|
369
|
+
// Init Nuxt.js
|
370
|
+
|
371
|
+
const nuxt = new Nuxt(config)
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
const { host, port } = nuxt.options.server
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
// Build only in dev mode
|
380
|
+
|
381
|
+
if (config.dev) {
|
382
|
+
|
383
|
+
const builder = new Builder(nuxt)
|
384
|
+
|
385
|
+
await builder.build()
|
386
|
+
|
387
|
+
} else {
|
388
|
+
|
389
|
+
await nuxt.ready()
|
390
|
+
|
391
|
+
}
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
// Give nuxt middleware to express
|
396
|
+
|
397
|
+
app.use(nuxt.render)
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
// Listen the server
|
402
|
+
|
403
|
+
app.listen(port, host)
|
404
|
+
|
405
|
+
consola.ready({
|
406
|
+
|
407
|
+
message: `Server listening on http://${host}:${port}`,
|
408
|
+
|
409
|
+
badge: true
|
410
|
+
|
411
|
+
})
|
412
|
+
|
413
|
+
}
|
414
|
+
|
415
|
+
start()
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
```
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
エラー内容
|
424
|
+
|
425
|
+
```bash
|
426
|
+
|
427
|
+
* ./server/index.ts in multi ./server/index.ts
|
428
|
+
|
429
|
+
```
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -245,3 +245,9 @@
|
|
245
245
|
Cannot read property '$get' of undefined
|
246
246
|
|
247
247
|
```
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
## 追記
|
252
|
+
|
253
|
+
どうやらnuxt.config.tsに問題がありそうです。
|
1
nuxt.configの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,6 +58,186 @@
|
|
58
58
|
|
59
59
|
|
60
60
|
|
61
|
+
```ts
|
62
|
+
|
63
|
+
// nuxt.config.ts
|
64
|
+
|
65
|
+
import NuxtConfiguration from '@nuxt/config'
|
66
|
+
|
67
|
+
const pkg = require('./package')
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
const nuxtConfig: NuxtConfiguration = {
|
72
|
+
|
73
|
+
mode: 'universal',
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
/*
|
78
|
+
|
79
|
+
** Headers of the page
|
80
|
+
|
81
|
+
*/
|
82
|
+
|
83
|
+
head: {
|
84
|
+
|
85
|
+
title: pkg.name,
|
86
|
+
|
87
|
+
meta: [
|
88
|
+
|
89
|
+
{ charset: 'utf-8' },
|
90
|
+
|
91
|
+
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
92
|
+
|
93
|
+
{ hid: 'description', name: 'description', content: pkg.description }
|
94
|
+
|
95
|
+
],
|
96
|
+
|
97
|
+
link: [
|
98
|
+
|
99
|
+
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
|
100
|
+
|
101
|
+
]
|
102
|
+
|
103
|
+
},
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
/*
|
108
|
+
|
109
|
+
** Customize the progress-bar color
|
110
|
+
|
111
|
+
*/
|
112
|
+
|
113
|
+
loading: { color: '#fff' },
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
/*
|
118
|
+
|
119
|
+
** Global CSS
|
120
|
+
|
121
|
+
*/
|
122
|
+
|
123
|
+
css: [
|
124
|
+
|
125
|
+
],
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
/*
|
130
|
+
|
131
|
+
** Plugins to load before mounting the App
|
132
|
+
|
133
|
+
*/
|
134
|
+
|
135
|
+
plugins: [
|
136
|
+
|
137
|
+
{ src: '~/plugins/swiper', ssr: false },
|
138
|
+
|
139
|
+
{ src: '@/plugins/axios.js', ssr: false }
|
140
|
+
|
141
|
+
],
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
/*
|
146
|
+
|
147
|
+
** Nuxt.js modules
|
148
|
+
|
149
|
+
*/
|
150
|
+
|
151
|
+
modules: [
|
152
|
+
|
153
|
+
// Doc: https://axios.nuxtjs.org/usage
|
154
|
+
|
155
|
+
'@nuxtjs/axios',
|
156
|
+
|
157
|
+
'@nuxtjs/pwa',
|
158
|
+
|
159
|
+
'@nuxtjs/auth'
|
160
|
+
|
161
|
+
],
|
162
|
+
|
163
|
+
/*
|
164
|
+
|
165
|
+
** Axios module configuration
|
166
|
+
|
167
|
+
*/
|
168
|
+
|
169
|
+
axios: {
|
170
|
+
|
171
|
+
// proxyHeaders: false
|
172
|
+
|
173
|
+
},
|
174
|
+
|
175
|
+
auth: {
|
176
|
+
|
177
|
+
strategies: {
|
178
|
+
|
179
|
+
facebook: {
|
180
|
+
|
181
|
+
client_id: '1598674820436253',
|
182
|
+
|
183
|
+
userinfo_endpoint: 'https://graph.facebook.com/v2.12/me?fields=about,name,picture{url},email,birthday',
|
184
|
+
|
185
|
+
scope: ['public_profile', 'email', 'user_birthday']
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
},
|
192
|
+
|
193
|
+
/*
|
194
|
+
|
195
|
+
** Build configuration
|
196
|
+
|
197
|
+
*/
|
198
|
+
|
199
|
+
build: {
|
200
|
+
|
201
|
+
/*
|
202
|
+
|
203
|
+
** You can extend webpack config here
|
204
|
+
|
205
|
+
*/
|
206
|
+
|
207
|
+
extend(config, ctx) {
|
208
|
+
|
209
|
+
if (ctx.isDev && ctx.isClient) {
|
210
|
+
|
211
|
+
if (!config.module) return
|
212
|
+
|
213
|
+
config.module.rules.push({
|
214
|
+
|
215
|
+
enforce: 'pre',
|
216
|
+
|
217
|
+
test: /.(js|vue)$/,
|
218
|
+
|
219
|
+
loader: 'eslint-loader',
|
220
|
+
|
221
|
+
exclude: /(node_modules)/
|
222
|
+
|
223
|
+
})
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
export default nuxtConfig
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
```
|
238
|
+
|
239
|
+
|
240
|
+
|
61
241
|
## エラー内容
|
62
242
|
|
63
243
|
```bash
|