Sails.js - How do I change the node.js module used by sails?
I want to write my own ejs-locals node module, but I also want the sails to use mine and I don't want to change the sails packages.json
.
How can I load, after sails have loaded their module ejs-locals
, my own module, to override it?
If there is a correct way to do things like this, I'd like to know :) Thanks.
I tried to find an answer to the official documentation there: http://sailsjs.org/#/documentation/concepts/extending-sails
But there is nothing about this.
Edit:
I tried to use the attribute fn
in config/views.js
but it doesn't work as expected, I made an example here: https://github.com/Vadorequest/sails-custom-ejs-locals
Final edit:
It works great with the solution suggested as the accepted answer, just disable layout
or it will mess up your config.layout: false
source to share
You can use npm winding trimming. https://docs.npmjs.com/cli/shrinkwrap
Then edit npm-shrinkwrap.json
and under the sails section point ejs or ejs-lorals to your version
source to share