Comments (14)
@rpereira have you try res.render('index.jsx', data)
?
from express-react-views.
Going to close out since we don't have a reliable repro. Feel free to comment if you work one out and we can revisit.
from express-react-views.
Encountered the same issue today when upgrading my MERN project.
-Robert Baindourov
from express-react-views.
The <!doctype>
isn't valid jsx and could be causing a parse issue. Maybe that's just getting swallowed?
from express-react-views.
Hi @zpao,
I've removed the <!doctype>
and the same problem persists.
from express-react-views.
I tried to reproduce this and I'm having trouble doing so reliably. I did get it to happen once but not a 2nd time (I did have some babel preset issues though, will need to look into that more). The only way I can repro reliably is if I name the file index.js
instead of index.jsx
.
If you had a reproducible test app I could look at, that might be helpful.
from express-react-views.
@ruiafonsopereira are you still having issues?
from express-react-views.
Hi @zpao,
I had to drop that experiment because I got stuck. If you give me a few days to try and set up a reproducible test app I can get back to you. If you prefer to close this issue in the meantime, go ahead and I'll let you know if the problem persists.
Thanks.
from express-react-views.
I have the same issue, is not finding the views and looks like the settings object in options is undefined:
TypeError: Cannot read property 'views' of undefined
at View.renderFile as engine
at View.render (/projects/modul/node_modules/express/lib/view.js:126:8)
at tryRender (/projects/modul/node_modules/express/lib/application.js:639:10)
at EventEmitter.render (/projects/modul/node_modules/express/lib/application.js:591:3)
at ServerResponse.render (/projects/modul/node_modules/express/lib/response.js:960:7)
at /projects/modul/core/routes/errors.js:27:11
at Layer.handle_error (/projects/modul/node_modules/express/lib/router/layer.js:71:5)
at trim_prefix (/projects/modul/node_modules/express/lib/router/index.js:310:13)
at /projects/modul/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/projects/modul/node_modules/express/lib/router/index.js:330:12)
from express-react-views.
I had it because my index was name index.js
instead of index.jsx
.
Because I don't want to have .jsx
I did this :
app.set('view engine', 'js')
app.engine('js', expressReactViews.createEngine({})
from express-react-views.
Hi @azopyros. To be honest, I don't remember given it was last year.
from express-react-views.
Encountered the same issue today when upgrading my MERN project.
-Robert Baindourov
Same here
from express-react-views.
I have the same issue. When I move the views
directory to the root, the views are resolved successfully, but when I move views
into a subfolder, view resolution stops working with the same error message as experienced by @rpereira.
Infact, removing the entire app.set('views', …)
statement makes no difference; the views
directory only works when it's situated at the root.
@rpereira have you try
res.render('index.jsx', data)
?
Adding .jsx
to the view name makes no difference to me. It seems like the React view engine completely ignores the path set with app.set('views', …)
.
from express-react-views.
For anyone trying to use this with TypeScript just use express-tsx-views
instead.
from express-react-views.
Related Issues (20)
- onClick event listener not working
- babel-register not updated in release from nine months ago HOT 2
- document is not defined HOT 1
- Feature request: Locals as a context HOT 3
- Error: Cannot find module 'babel-core' HOT 3
- Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3" HOT 3
- If we need a view engine of ‘tsx’.
- Dynamic example is vulnerable to XSS HOT 2
- React component use HOT 1
- Dealing with different file extensions for production HOT 1
- Any plans for webpack support?
- SyntaxError: Unexpected token '<'
- Error: Cannot find module '@babel/plugin-transform-flow-strip-types'
- cannot import bootstrap when using the jsx view engine HOT 4
- Is this reactive? HOT 3
- React Dev Tools Does Not Comprehend React Components HOT 1
- React setState did not rerender the page HOT 4
- add external script file
- How to load javascript with express-react-views HOT 2
- React 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-react-views.