質問編集履歴
4
書式改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -147,7 +147,7 @@
|
|
147
147
|
return config
|
148
148
|
}
|
149
149
|
}
|
150
|
-
``
|
150
|
+
```
|
151
151
|
|
152
152
|
/server/index.ts
|
153
153
|
```ts
|
3
より詳細なソースの共有
title
CHANGED
File without changes
|
body
CHANGED
@@ -124,4 +124,92 @@
|
|
124
124
|
```
|
125
125
|
|
126
126
|
## 追記
|
127
|
-
どうやらnuxt.config.tsに問題がありそうです。
|
127
|
+
どうやらnuxt.config.tsに問題がありそうです。
|
128
|
+
backpack-core経由で起動しているのですが、
|
129
|
+
その際にnuxt.config.tsの読み込みに失敗してるみたいです。
|
130
|
+
|
131
|
+
backpack.config.js
|
132
|
+
```js
|
133
|
+
module.exports = {
|
134
|
+
webpack: (config) => {
|
135
|
+
config.entry.main = [
|
136
|
+
'./server/index.ts'
|
137
|
+
]
|
138
|
+
config.resolve = {
|
139
|
+
extensions: ['.ts', '.js', '.json']
|
140
|
+
}
|
141
|
+
config.module.rules.push(
|
142
|
+
{
|
143
|
+
test: /.ts$/,
|
144
|
+
loader: 'awesome-typescript-loader'
|
145
|
+
}
|
146
|
+
)
|
147
|
+
return config
|
148
|
+
}
|
149
|
+
}
|
150
|
+
``
|
151
|
+
|
152
|
+
/server/index.ts
|
153
|
+
```ts
|
154
|
+
import express from 'express'
|
155
|
+
import consola from 'consola'
|
156
|
+
import { Nuxt, Builder } from 'nuxt'
|
157
|
+
import bodyParser from 'body-parser'
|
158
|
+
import session from 'express-session'
|
159
|
+
import cookieParser from 'cookie-parser'
|
160
|
+
import csrf from 'csurf'
|
161
|
+
import api from './api'
|
162
|
+
const app = express()
|
163
|
+
app.use(bodyParser.json())
|
164
|
+
app.use(bodyParser.urlencoded({
|
165
|
+
extended: true
|
166
|
+
}))
|
167
|
+
app.use(cookieParser())
|
168
|
+
app.use(session({
|
169
|
+
secret: 'example',
|
170
|
+
resave: false,
|
171
|
+
saveUninitialized: false,
|
172
|
+
cookie: {
|
173
|
+
maxage: 1000 * 60 * 30
|
174
|
+
}
|
175
|
+
}))
|
176
|
+
app.use(csrf({
|
177
|
+
cookie: true
|
178
|
+
}))
|
179
|
+
app.use('/api', api)
|
180
|
+
// Import and Set Nuxt.js options
|
181
|
+
const config = require('../nuxt.config.ts')
|
182
|
+
config.dev = !(process.env.NODE_ENV === 'production')
|
183
|
+
|
184
|
+
async function start() {
|
185
|
+
// Init Nuxt.js
|
186
|
+
const nuxt = new Nuxt(config)
|
187
|
+
|
188
|
+
const { host, port } = nuxt.options.server
|
189
|
+
|
190
|
+
// Build only in dev mode
|
191
|
+
if (config.dev) {
|
192
|
+
const builder = new Builder(nuxt)
|
193
|
+
await builder.build()
|
194
|
+
} else {
|
195
|
+
await nuxt.ready()
|
196
|
+
}
|
197
|
+
|
198
|
+
// Give nuxt middleware to express
|
199
|
+
app.use(nuxt.render)
|
200
|
+
|
201
|
+
// Listen the server
|
202
|
+
app.listen(port, host)
|
203
|
+
consola.ready({
|
204
|
+
message: `Server listening on http://${host}:${port}`,
|
205
|
+
badge: true
|
206
|
+
})
|
207
|
+
}
|
208
|
+
start()
|
209
|
+
|
210
|
+
```
|
211
|
+
|
212
|
+
エラー内容
|
213
|
+
```bash
|
214
|
+
* ./server/index.ts in multi ./server/index.ts
|
215
|
+
```
|
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -121,4 +121,7 @@
|
|
121
121
|
## エラー内容
|
122
122
|
```bash
|
123
123
|
Cannot read property '$get' of undefined
|
124
|
-
```
|
124
|
+
```
|
125
|
+
|
126
|
+
## 追記
|
127
|
+
どうやらnuxt.config.tsに問題がありそうです。
|
1
nuxt.configの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -28,6 +28,96 @@
|
|
28
28
|
})
|
29
29
|
```
|
30
30
|
|
31
|
+
```ts
|
32
|
+
// nuxt.config.ts
|
33
|
+
import NuxtConfiguration from '@nuxt/config'
|
34
|
+
const pkg = require('./package')
|
35
|
+
|
36
|
+
const nuxtConfig: NuxtConfiguration = {
|
37
|
+
mode: 'universal',
|
38
|
+
|
39
|
+
/*
|
40
|
+
** Headers of the page
|
41
|
+
*/
|
42
|
+
head: {
|
43
|
+
title: pkg.name,
|
44
|
+
meta: [
|
45
|
+
{ charset: 'utf-8' },
|
46
|
+
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
47
|
+
{ hid: 'description', name: 'description', content: pkg.description }
|
48
|
+
],
|
49
|
+
link: [
|
50
|
+
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
|
51
|
+
]
|
52
|
+
},
|
53
|
+
|
54
|
+
/*
|
55
|
+
** Customize the progress-bar color
|
56
|
+
*/
|
57
|
+
loading: { color: '#fff' },
|
58
|
+
|
59
|
+
/*
|
60
|
+
** Global CSS
|
61
|
+
*/
|
62
|
+
css: [
|
63
|
+
],
|
64
|
+
|
65
|
+
/*
|
66
|
+
** Plugins to load before mounting the App
|
67
|
+
*/
|
68
|
+
plugins: [
|
69
|
+
{ src: '~/plugins/swiper', ssr: false },
|
70
|
+
{ src: '@/plugins/axios.js', ssr: false }
|
71
|
+
],
|
72
|
+
|
73
|
+
/*
|
74
|
+
** Nuxt.js modules
|
75
|
+
*/
|
76
|
+
modules: [
|
77
|
+
// Doc: https://axios.nuxtjs.org/usage
|
78
|
+
'@nuxtjs/axios',
|
79
|
+
'@nuxtjs/pwa',
|
80
|
+
'@nuxtjs/auth'
|
81
|
+
],
|
82
|
+
/*
|
83
|
+
** Axios module configuration
|
84
|
+
*/
|
85
|
+
axios: {
|
86
|
+
// proxyHeaders: false
|
87
|
+
},
|
88
|
+
auth: {
|
89
|
+
strategies: {
|
90
|
+
facebook: {
|
91
|
+
client_id: '1598674820436253',
|
92
|
+
userinfo_endpoint: 'https://graph.facebook.com/v2.12/me?fields=about,name,picture{url},email,birthday',
|
93
|
+
scope: ['public_profile', 'email', 'user_birthday']
|
94
|
+
}
|
95
|
+
}
|
96
|
+
},
|
97
|
+
/*
|
98
|
+
** Build configuration
|
99
|
+
*/
|
100
|
+
build: {
|
101
|
+
/*
|
102
|
+
** You can extend webpack config here
|
103
|
+
*/
|
104
|
+
extend(config, ctx) {
|
105
|
+
if (ctx.isDev && ctx.isClient) {
|
106
|
+
if (!config.module) return
|
107
|
+
config.module.rules.push({
|
108
|
+
enforce: 'pre',
|
109
|
+
test: /.(js|vue)$/,
|
110
|
+
loader: 'eslint-loader',
|
111
|
+
exclude: /(node_modules)/
|
112
|
+
})
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
export default nuxtConfig
|
118
|
+
|
119
|
+
```
|
120
|
+
|
31
121
|
## エラー内容
|
32
122
|
```bash
|
33
123
|
Cannot read property '$get' of undefined
|