Nuxt.js: npm start error 【serve/index.js params promise is undefined】

Created on 25 Mar 2019  ·  5Comments  ·  Source: nuxt/nuxt.js

Version

v2.3.2 (koa)

Reproduction link

init project

Steps to reproduce

  1. npx create-nuxt-app nuxt-demo
  2. npm install
  3. npm run build
  4. npm start
  5. Server side reported promise. Then method not found, in the server/index.js print, found the promise parameter is undefined

    What is expected ?

Hope NPM start works properly

What is actually happening?

app.use(ctx => { ctx.status = 200 return new Promise((resolve, reject) => { ctx.res.on('close', resolve) ctx.res.on('finish', resolve) nuxt.render(ctx.req, ctx.res, promise => { // **promise is undefied** promise.then(resolve).catch(reject) }) }) })

Additional comments?

I hope the authorities can pay attention to it, which leads to difficulties in deployment

This question is available on Nuxt community (#c8914)

Most helpful comment

This issue as been imported as question since it does not respect nuxt.js issue template. Only bug reports and feature requests stays open to reduce maintainers workload.
If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically.
Your question is available at https://cmty.app/nuxt/nuxt.js/issues/c8914.

fuck

All 5 comments

This issue as been imported as question since it does not respect nuxt.js issue template. Only bug reports and feature requests stays open to reduce maintainers workload.
If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically.
Your question is available at https://cmty.app/nuxt/nuxt.js/issues/c8914.

This issue as been imported as question since it does not respect nuxt.js issue template. Only bug reports and feature requests stays open to reduce maintainers workload.
If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically.
Your question is available at https://cmty.app/nuxt/nuxt.js/issues/c8914.

fuck

Same issue here. Could you fix this problem?

I created a new Nuxt project then copied its /server folder to the current project.

It was fixed now!

@zlgb-wow

nuxt.render is a reference of connect.js app, unfortunately there is no promise as a parameter of the callback, so you may try:

app.use((ctx) => {
  ctx.status = 200
  return new Promise((resolve, reject) => {
    ctx.res.on('close', resolve)
    ctx.res.on('finish', resolve)
    nuxt.render(ctx.req, ctx.res, err => err ? resolve() : reject(err))
  })
})

And about your code, is it from any official Nuxt module or repo ? If so, could you please send me the link and I'll fix it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pehbehbeh picture pehbehbeh  ·  3Comments

bimohxh picture bimohxh  ·  3Comments

mattdharmon picture mattdharmon  ·  3Comments

maicong picture maicong  ·  3Comments

o-alexandrov picture o-alexandrov  ·  3Comments