Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting views option as an array of paths gives an error #3976

Closed
Jusys opened this issue Jun 4, 2019 · 3 comments
Closed

setting views option as an array of paths gives an error #3976

Jusys opened this issue Jun 4, 2019 · 3 comments

Comments

@Jusys
Copy link

Jusys commented Jun 4, 2019

Using node v12.2.0
Using express v4.17.1
Using express-handlebars v3.0.2
Using Windows 7

Documentation clearly states, that:
image

My code is like:
let _views = ['some-path/views1']
_ex.set('views', _views)

But when I try to use an array of view paths I get an error:

TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received type object
    at validateString (internal/validators.js:107:11)
    at Object.relative (path.js:434:5)
    at ExpressHandlebars.renderView (c:\my-project\node_modules\express-handlebars\lib\express-handlebars.js:193:43)
    at View.render (c:\my-project\node_modules\express\lib\view.js:135:8)
    at tryRender (c:\my-project\node_modules\express\lib\application.js:640:10)
    at Function.render (c:\my-project\node_modules\express\lib\application.js:592:3)
    at ServerResponse.render (c:\my-project\node_modules\express\lib\response.js:1012:7)
    at c:\my-project\web\views\main-default.js:6:10
    at Layer.handle [as handle_request] (c:\my-project\node_modules\express\lib\router\layer.js:95:5)
    at next (c:\my-project\node_modules\express\lib\router\route.js:137:13)
@dougwilson
Copy link
Contributor

From the stack trace, it looks like the express-handlebars library you are using is not compatible with views as array support, maybe? Since the exception is in that module and not Express.

If you think it is Express, can you provide a complete app we can run that reproduces that error stack and we can take a closer look to understand what the issue is.

@dougwilson
Copy link
Contributor

I searched the express-handlebars module and indeed, this is caused because that view engine is accessing the configured views directory and doesn't support array views. There is a PR in that repo to add the array support: ericf/express-handlebars#209

@Jusys
Copy link
Author

Jusys commented Jun 5, 2019

Thank you for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants