Edit Page

Disabling globals

Sails determines which globals to expose by looking at sails.config.globals, which is conventionallly configured in config/globals.js.

To disable all global variables, just set the setting to false:

// config/globals.js
module.exports.globals = false;

To disable some global variables, specify an object instead, e.g.:

// config/globals.js
module.exports.globals = {
  _: false,
  async: false,
  models: false,
  services: false
};

Notes

#
  • Bear in mind that none of the globals, including sails, are accessible until after sails has loaded. In other words, you won't be able to use sails.models.user or User outside of a function (since sails will not have finished loading yet.)

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Concepts