I'm trying to use EJS with typescript, I can use res.send
app.set('views', path.join(__dirname, 'src/views/'));
app.set('view engine', 'ejs');
app.get('/index', function (req, res, next) {
res.send('hello')
});
But, when I try to use render
method I get Error: Cannot find module 'ejs'
. I'm sure that I installed ejs as globally and locally. What can cause that?
EJS is not made to work with TypeScript natively.
Please check here how to properly set that up to be integrated in Express:
https://developer.okta.com/blog/2018/11/15/node-express-typescript
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.