Answer the question
In order to leave comments, you need to log in
How to set a global variable in sails.js like in lodash?
In sails.js, you can call lodash this way _.sort()
anywhere in the project. For example, there is a key
in globals.js_: require('lodash')
.
If you add there moment: require('moment')
, it will not work.
How to set a similar way of calling, only for moment.js?
Answer the question
In order to leave comments, you need to log in
lodash
They write about
it in the Sails documentation:
Async (async
) and Lodash (_
)
Sails also exposes an instance of lodash as_
, and an instance of async asasync
. These commonly-used utilities are provided by default so that you don't have to npm install them in every new project. Like any of the other globals in sails, they can be disabled.
globals.js
is only meant to disable some default globals:// config/globals.js
module.exports.globals = {
_: false,
async: false,
models: false,
services: false
};
_: require('lodash')
_: true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question