_nuxt2.default is not a constructor
来源:4-2 构建初始项目首次验证公众号服务器
精慕门0750041
2017-11-20
index.js
import Koa from 'koa' import Nuxt from 'nuxt' import R from 'ramda' import { resolve } from 'path' // Import and Set Nuxt.js options let config = require('../nuxt.config.js'); config.dev = !(process.env === 'production'); const r = path =>resolve(__dirname,path); const host = process.env.HOST || '127.0.0.1'; const port = process.env.PORT || 3000; const MIDDLEWARES = ['router']; class Server { constructor (){ this.app = new Koa(); this.useMiddleWares(this.app)(MIDDLEWARES); } useMiddleWares (app){ return R.map(R.compose( R.map(i => i(app)), require, i => `${r('./middleware')}/${i}` )) } async start (){ // Instantiate nuxt.js const nuxt = await new Nuxt(config); // Build in development if (config.dev) { try{ await nuxt.build() } catch (e){ console.error(e); // eslint-disable-line no-console process.exit(1) } } this.app.use(async (ctx,next) => { ctx.status = 200 ;// koa defaults to 404 when it sees that status is unset await nuxt.render(ctx,req,ctx.res) }); this.app.listen(port, host); console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console } } const app = new Server(); app.start();
写回答
1回答
-
nuxt 回归到这个版本看下有没有问题
nuxt@~1.0.0-alpha1: version "1.0.0-alpha2" resolved " http://registry.npm.taobao.org/nuxt/download/nuxt-1.0.0-alpha2.tgz#03366dd8384406b26b1eeff06f7f2b12a6f40c00"
怀疑是 nuxt 后面升级了后,导致不兼容了
012017-12-01
相似问题