NodeJs - esc is not a function

前端 未结 3 2051
栀梦
栀梦 2021-02-14 20:55

I got a weird issues when trying to render an .ejs file at this specific lines

TypeError: /home/me/nodeapp/app/views/default/page/connection.ejs:66
             


        
3条回答
  •  别那么骄傲
    2021-02-14 21:53

    I don't have reputation to comment so .... I just saw the same symptom. In my case I accidentally changed "currentUser.name" to "currentUser.Name" (uppercase "N") from a sample in the book "Express In Action", section 8.

    in routes.js

    var passport = require( "passport" );
    router.use( function( req, res, next ) {
        res.locals.currentUser = req.user;
    }
    

    views/_header.ejs

    
        Hello <%= currentUser.Name() %>
    
    

    when I changed back to "currentUser.name" the TypeError disappeared

提交回复
热议问题