【发布时间】:2018-12-28 12:37:50
【问题描述】:
我想在 nuxt 中启用 github 页面进行部署。在docs 之后,虽然我无法在 conf 文件中得到正确的结果。
这是他们要在文件中添加的内容。我在文件中的多个位置添加了它,但每次都出错。
/* nuxt.config.js */
// only add `router.base = '/<repository-name>/'` if `DEPLOY_ENV` is `GH_PAGES`
const routerBase = process.env.DEPLOY_ENV === 'GH_PAGES' ? {
router: {
base: '/<repository-name>/'
}
} : {}
export default {
...routerBase
}
我的导出代码。
module.exports = {
mode: 'spa',
const routerBase = process.env.DEPLOY_ENV === 'GH_PAGES' ?
{router: {base: '/mortalcatalyst.github.io/'}} :
{} export default {router: {base: '/mortalcatalyst.github.io/'}},
/*
** Headers of the page
*/
head: {
title: pkg.name,
meta: [
{charset: 'utf-8'},
{name: 'viewport', content: 'width=device-width, initial-scale=1'},
{hid: 'description', name: 'description', content: pkg.description}
],
link: [{rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}]
}, # rest of config (standard)
错误
FATAL Invalid or unexpected token 22:06:37
const routerBase = process.env.DEPLOY_ENV === 'GH_PAGES' ? {
^
SyntaxError: Invalid or unexpected token
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
╭──────────────────────────────────────────────╮
│ │
│ ✖ Nuxt Fatal Error │
│ │
│ SyntaxError: Invalid or unexpected token │
│ │
╰──────────────────────────────────────────────╯
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! github@1.0.0 generate: `nuxt generate`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the github@1.0.0 generate script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
【问题讨论】: