How do I use express react expressions in Sails.js?

I tried to implement express react expressions in Sailsjs by setting engine: 'jsx',

to config/views.js

, but it returns the following error:

info: Starting app...

warn: [Function]
error: Invalid view engine (jsx)-- are you sure it supports `consolidate`?
error: Your configured server-side view engine (jsx) could not be found.
error: Usually, this just means you need to install a dependency.
error: To install jsx, run:  `npm install jsx --save`
error: Otherwise, please change your `engine` configuration in config/views.js.
/Users/henry/Documents/dev/node/project/server/node_modules/sails/lib/hooks/views/configure.js:75
            throw e;
                  ^
Error

      

How do I correctly use Express Response Expressions in a Sails project?

+3


source to share


1 answer


If you follow this tutorial you will see that you need to install the engine

engine: {
  ext: 'jsx',
  fn: require('express-react-views').createEngine()
}

      



after setting Express Response, Response and Response Expressions. For me the tutorial worked fine when setting the file extension of the view files to jsx.

+2


source







All Articles