javascript - How to include services from an npm module in Sails.js? -


i have utility services want package node module include in multiple sails.js projects.

i know files included in api\services\ directory gets included on global scope automatically.

how include service on global scope node module, not located in services folder?

i don't want link them grunt or make kind of copy, either. have grunt disabled projects.

i tend refer libraries in services folder. utilservice.js use bunch of libraries.

api/services/utilservice.js

var changecase = require("change-case"),     moment = require("moment"),     numeral = require("numeral");  module.exports = {     numeral : numeral,      moment : moment,      changecase : changecase } 

now each of these libraries referenced globally:

utilservice.numeral() utilservice.moment() utilservice.changecase() 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -