You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello there, I'm trying to create a really basic app using Nuxt as a middleware and I got an issue when I try to access the server.
Here is the complete error message: The message appear both in the browser and the terminal
TypeError: Cannot read property 'renderer' of undefined at render (/home/vincent/WebstormProjects/nuxtExpress/node_modules/nuxt/lib/nuxt.js:94:14) at Layer.handle [as handle_request] (/home/vincent/WebstormProjects/nuxtExpress/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/home/vincent/WebstormProjects/nuxtExpress/node_modules/express/lib/router/index.js:312:13) at /home/vincent/WebstormProjects/nuxtExpress/node_modules/express/lib/router/index.js:280:7 at Function.process_params (/home/vincent/WebstormProjects/nuxtExpress/node_modules/express/lib/router/index.js:330:12) at next (/home/vincent/WebstormProjects/nuxtExpress/node_modules/express/lib/router/index.js:271:10) at expressInit (/home/vincent/WebstormProjects/nuxtExpress/node_modules/express/lib/middleware/init.js:33:5) at Layer.handle [as handle_request] (/home/vincent/WebstormProjects/nuxtExpress/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/home/vincent/WebstormProjects/nuxtExpress/node_modules/express/lib/router/index.js:312:13) at /home/vincent/WebstormProjects/nuxtExpress/node_modules/express/lib/router/index.js:280:7
The check in the render function in lib/nuxt.js fails because this is actually undefined.
// nuxt.jsrender(req,res){if(!this.renderer){// <--- Here this is undefinedsetTimeout(()=>{this.render(req,res)},1000)return}// ...
This may be caused by my code? I'm probably doing something wrong in this file.
// app.js (at project's root)constexpress=require('express');constapp=express();constNuxt=require('nuxt');constnuxtConfig=require('./config/nuxt.config');newNuxt(nuxtConfig).then((nuxt)=>{app.use(nuxt.render);app.listen(3000,function(){console.log('listening port 3000 -> http://localhost:3000');});}).catch((error)=>{console.log(error);});
I solved the problem by binding the render function 👍
constexpress=require('express');constapp=express();constNuxt=require('nuxt');constnuxtConfig=require('./config/nuxt.config');newNuxt(nuxtConfig).then((nuxt)=>{letrender=nuxt.render;app.use(render.bind(nuxt));app.listen(3000,function(){console.log('listening port 3000 -> http://localhost:3000')});}).catch((error)=>{console.log(error);});
Hello there, I'm trying to create a really basic app using Nuxt as a middleware and I got an issue when I try to access the server.
Here is the complete error message:
The message appear both in the browser and the terminal
The check in the
render
function inlib/nuxt.js
fails becausethis
is actually undefined.This may be caused by my code? I'm probably doing something wrong in this file.
Thanks, and keep up the good work! 👍
The text was updated successfully, but these errors were encountered: