{"record":{"id":"dbaf564b5b9d37fb","repo":"balderdashy/sails","slug":"detected-sails-environment-of-production-but-no","errorCode":null,"errorMessage":"Detected Sails environment of `production`, but Node environment is `${process.env.NODE_ENV}`.\nIt is recommended that in production mode, both the Sails and Node environments be set to `production`.","messagePattern":"Detected Sails environment of `production`, but Node environment is `(.+?)`\\.\nIt is recommended that in production mode, both the Sails and Node environments be set to `production`\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/app/load.js","lineNumber":275,"sourceCode":"   */\n  function ready__(cb) {\n    return function(err) {\n      if (err) {\n        return cb && cb(err);\n      }\n\n      sails.log.silly('The router & all hooks were loaded successfully.');\n\n      // If userconfig hook is turned off, still load globals.\n      if (sails.config.hooks && sails.config.hooks.userconfig === false ||\n           (sails.config.loadHooks && sails.config.loadHooks.indexOf('userconfig') === -1)) {\n        sails.exposeGlobals();\n      }\n\n      // If the Sails environment is set to \"production\" but the Node environment isn't,\n      // log a warning.\n      if (sails.config.environment === 'production' && process.env.NODE_ENV !== 'production') {\n        sails.log.warn('Detected Sails environment of `production`, but Node environment is `' + process.env.NODE_ENV + '`.\\n' +\n                       'It is recommended that in production mode, both the Sails and Node environments be set to `production`.');\n      }\n\n      cb && cb(null, sails);\n    };\n  }\n\n  //    ██╗    ██╗    ██╗███╗   ██╗██╗     ██╗███╗   ██╗███████╗    ███████╗███╗   ██╗    ██████╗ ███████╗███████╗███████╗    ██╗\n  //   ██╔╝   ██╔╝    ██║████╗  ██║██║     ██║████╗  ██║██╔════╝    ██╔════╝████╗  ██║    ██╔══██╗██╔════╝██╔════╝██╔════╝    ╚██╗\n  //  ██╔╝   ██╔╝     ██║██╔██╗ ██║██║     ██║██╔██╗ ██║█████╗      █████╗  ██╔██╗ ██║    ██║  ██║█████╗  █████╗  ███████╗     ╚██╗\n  //  ╚██╗  ██╔╝      ██║██║╚██╗██║██║     ██║██║╚██╗██║██╔══╝      ██╔══╝  ██║╚██╗██║    ██║  ██║██╔══╝  ██╔══╝  ╚════██║     ██╔╝\n  //   ╚██╗██╔╝       ██║██║ ╚████║███████╗██║██║ ╚████║███████╗    ██║     ██║ ╚████║    ██████╔╝███████╗██║     ███████║    ██╔╝\n  //    ╚═╝╚═╝        ╚═╝╚═╝  ╚═══╝╚══════╝╚═╝╚═╝  ╚═══╝╚══════╝    ╚═╝     ╚═╝  ╚═══╝    ╚═════╝ ╚══════╝╚═╝     ╚══════╝    ╚═╝\n  //\n  // </ inline function declarations (see note above) >\n  // ==============================================================================\n\n","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/balderdashy/sails/blob/7b76422cc27823df033572bdda5c4910a68b697f/lib/app/load.js#L257-L293","documentation":"A warning raised in ready__ during app load: Sails' own environment (sails.config.environment) is set to 'production' but the Node process environment variable NODE_ENV is not 'production'. Sails warns because many libraries (Express middleware, ORM drivers, caching) key their behavior off NODE_ENV, and a mismatch can silently disable production optimizations or enable development behavior.","triggerScenarios":"Lifting with NODE_ENV unset or set to something other than 'production' while config/environment (or the --prod flag / NODE_ENV mapping) resolves sails.config.environment to 'production'.","commonSituations":"Deploying to a server where the process manager (pm2, systemd, docker) was not configured to pass NODE_ENV=production; running 'sails lift --prod' locally without exporting NODE_ENV; Docker images that set SAILS environment in config but not the OS env var.","solutions":["Set NODE_ENV=production in the environment before lifting (export NODE_ENV=production or configure it in pm2/systemd/Dockerfile).","Start the app with NODE_ENV=production node app.js --prod.","If you actually want a non-production Sails environment, change sails.config.environment accordingly so the two match."],"exampleFix":"// before (package.json)\n\"start\": \"node app.js\"\n// after\n\"start\": \"NODE_ENV=production node app.js --prod\"","handlingStrategy":"validation","validationCode":"if (process.env.NODE_ENV !== 'production') {\n  console.warn('NODE_ENV is not \"production\"; production lifts will warn. Set NODE_ENV=production.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set NODE_ENV=production in pm2/systemd/Docker env config for every prod deployment.","Add a preflight check or startup assertion comparing NODE_ENV with sails.config.environment.","Document the required env vars in your deployment runbook."],"tags":["environment","node-env","production","configuration"],"backgroundTag":"environment-mismatch","analyzedSha":"7b76422cc27823df033572bdda5c4910a68b697f","analyzedAt":"2026-09-01T04:01:57.104Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}