{"record":{"id":"3bdf357c3e622407","repo":"balderdashy/sails","slug":"e-bad-global-config","errorCode":"E_BAD_GLOBAL_CONFIG","errorMessage":"As of Sails v1, if `sails.config.globals` is defined, it must either be `false` or a dictionary (plain JavaScript object) or `false`.  But instead, got: '+util.inspect(sails.config.globals, {depth:null})+'\\n> Note: if no globals are desired, set `sails.config.globals` to `false`.","messagePattern":"As of Sails v1, if `sails\\.config\\.globals` is defined, it must either be `false` or a dictionary \\(plain JavaScript object\\) or `false`\\.  But instead, got: '\\+util\\.inspect\\(sails\\.config\\.globals, (.+?)\\)\\+'\\\\n> Note: if no globals are desired, set `sails\\.config\\.globals` to `false`\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/app/private/exposeGlobals.js","lineNumber":39,"sourceCode":"\nmodule.exports = function exposeGlobals() {\n  var sails = this;\n\n  // Implicit default for globals is `false`, to allow for intuitive programmatic\n  // usage of `sails.lift()`/`sails.load()` in automated tests, command-line scripts,\n  // scheduled jobs, etc.\n  //\n  // > Note that this is not the same as the boilerplate `config/globals.js` settings,\n  // > since the use of certain global variables is still the recommended approach for\n  // > the code you write in your Sails app's controller actions, etc.\n  if (_.isUndefined(sails.config.globals)) {\n    sails.config.globals = false;\n    return;\n  }\n\n  // If globals config is provided, it must be either `false` or a dictionary.\n  else if (sails.config.globals !== false && (!_.isObject(sails.config.globals) || _.isArray(sails.config.globals) || _.isFunction(sails.config.globals))) {\n    throw flaverr({ name: 'userError', code: 'E_BAD_GLOBAL_CONFIG' }, new Error('As of Sails v1, if `sails.config.globals` is defined, it must either be `false` or a dictionary (plain JavaScript object) or `false`.  But instead, got: '+util.inspect(sails.config.globals, {depth:null})+'\\n> Note: if no globals config is specified, Sails will now assume `false` (no globals).  This is to allow for more intuitive programmatic usage.\\nFor more info, see http://sailsjs.com/config/globals'));\n  }\n\n  // Globals explicitly disabled.\n  if (sails.config.globals === false) {\n    sails.log.verbose('No global variables will be exposed.');\n    return;\n  }\n\n  sails.log.verbose('Exposing global variables... (you can customize/disable this by modifying the properties in `sails.config.globals`.  Set it to `false` to disable all globals.)');\n\n  // `sails.config.globals._` must be false or an object.\n  // (it's probably a function with lots of extra properties, but to future-proof, we'll allow any type of object)\n  if (sails.config.globals._ !== false) {\n    if (!_.isObject(sails.config.globals._)) {\n      throw flaverr({ name: 'userError', code: 'E_BAD_GLOBAL_CONFIG' }, new Error('As of Sails v1, `sails.config.globals._` must be either `false` or a locally-installed version of Lodash (typically `require(\\'lodash\\')`).  For more info, see http://sailsjs.com/config/globals'));\n    }\n    global['_'] = sails.config.globals._;\n  }","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/balderdashy/sails/blob/7b76422cc27823df033572bdda5c4910a68b697f/lib/app/private/exposeGlobals.js#L21-L57","documentation":"Error \"As of Sails v1, if `sails.config.globals` is defined, it must either be `false` or a dictionary (plain JavaScript object) or `false`.  But instead, got: '+util.inspect(sails.config.globals, {depth:null})+'\\n> Note: if no globals are desired, set `sails.config.globals` to `false`.\" thrown in balderdashy/sails.","triggerScenarios":"Thrown at lib/app/private/exposeGlobals.js:39 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b76422cc27823df033572bdda5c4910a68b697f","analyzedAt":"2026-09-01T04:01:57.104Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}