Skip to content

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined when pass data contains a key name "settings" #43

@vt107

Description

@vt107

I got error

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at Object.join (node:path:1268:7)
at /Users/user/Documents/abc/node_modules/ejs-mate/lib/index.js:342:25
at tryHandleCache (/Users/user/Documents/abc/node_modules/ejs/lib/ejs.js:280:5)
at exports.renderFile (/Users/user/Documents/abc/node_modules/ejs/lib/ejs.js:491:10)
at View.renderFile [as engine] (/Users/user/Documents/abc/node_modules/ejs-mate/lib/index.js:298:7)
at View.render (/Users/user/Documents/abc/node_modules/express/lib/view.js:135:8)
at tryRender (/Users/user/Documents/abc/node_modules/express/lib/application.js:657:10)
at Function.render (/Users/user/Documents/abc/node_modules/express/lib/application.js:609:3)
at ServerResponse.render (/Users/user/Documents/abc/node_modules/express/lib/response.js:1049:7)
at /Users/user/Documents/abc/apps/controllers/admin/AdminSettingController.js:19:16

my render code is

    return res.render('admin/a', {
        settings: {},
    });

but strange that if I remove settings, or rename to settingsx or any thing else - it works.

my ejs config

const engine = require("ejs-mate");
app.engine("ejs", engine);
app.set("view engine", "ejs");

my a.ejs

<% layout("admin/layoutx") %>

<div class="form-group">
        hihi
</div>

my layoutx.ejs

<%- body %>

I think settings is conflict with some data of ejs-mate when control view

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions