{"record":{"id":"357d12476398a24f","repo":"balderdashy/sails","slug":"cannot-read-package-json-in-the-current-directory","errorCode":null,"errorMessage":"Cannot read package.json in the current directory (CWD)","messagePattern":"Cannot read package\\.json in the current directory \\(CWD\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"errors/warn.js","lineNumber":38,"sourceCode":"  incompatibleLocalSails: function(requiredVersion, localVersion) {\n    log.warn('Trying to lift app using a local copy of `sails`');\n    log.warn('(located in ' + nodepath.resolve(process.cwd(), 'node_modules/sails') + ')');\n    log.warn();\n    log.warn('But the package.json in the current directory indicates a dependency');\n    log.warn('on Sails `' + requiredVersion + '`, and the locally installed Sails is `' + localVersion + '`!');\n    log.warn();\n    log.warn('If you run into compatibility issues, try installing ' + requiredVersion + ' locally:');\n    log.warn('    $ npm install sails@' + requiredVersion);\n    log.warn();\n    log.blank();\n  },\n\n\n\n  // Verbose-only warnings:\n\n  noPackageJSON: function() {\n    log.warn('Cannot read package.json in the current directory (' + process.cwd() + ')');\n    log.warn('Are you sure this is a Sails app?');\n    log.warn();\n  },\n\n  notSailsApp: function() {\n    log.warn('The package.json in the current directory does not list Sails as a dependency...');\n    log.warn('Are you sure `' + process.cwd() + '` is a Sails app?');\n    log.warn();\n  },\n\n  badLocalDependency: function(pathToLocalSails, requiredVersion) {\n    log.warn(\n      'The local Sails dependency installed at `' + pathToLocalSails + '` ' +\n      'has a corrupted, missing, or un-parsable package.json file.'\n    );\n    log.warn('You may consider running:');\n    log.warn('rm -rf ' + pathToLocalSails + ' && npm install sails@' + requiredVersion);\n    log.warn();","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/balderdashy/sails/blob/7b76422cc27823df033572bdda5c4910a68b697f/errors/warn.js#L20-L56","documentation":"Warning from `noPackageJSON` in errors/warn.js:38 (a verbose-only warning). Sails could not read a package.json in the current working directory, so it cannot verify the app's dependencies. Sails prints the CWD it inspected to help the developer realize they lifted from the wrong folder.","triggerScenarios":"Running `sails lift` (with verbose warnings enabled) in a directory that has no package.json, or where package.json is unreadable/unparsable; the CLI's app-directory detection falls back to process.cwd().","commonSituations":"Lifting from the repo root instead of the app subfolder; running inside a directory that only contains source files; a deleted or malformed package.json; wrong working directory in a terminal or IDE run configuration.","solutions":["cd into the directory that contains your Sails app's package.json and run `sails lift` again.","If the app is new, run `sails new <app>` or create a package.json (`npm init`) with sails as a dependency.","If package.json exists but is broken, validate it (e.g. `node -e \"require('./package.json')\"`) and fix the JSON syntax."],"exampleFix":"// before (terminal)\n/home/me/project/server-files$ sails lift\n// after\ncd /home/me/project\nsails lift","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nif (!fs.existsSync(path.join(process.cwd(), 'package.json'))) {\n  throw new Error('No package.json in CWD; cd to your Sails app root before running sails lift');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always lift from the directory containing package.json, app.js and config/.","Configure IDE run configurations with the correct working directory.","Add package.json to version control (never gitignore it)."],"tags":["sails","package-json","cwd","missing-file"],"backgroundTag":"missing-package-json","analyzedSha":"7b76422cc27823df033572bdda5c4910a68b697f","analyzedAt":"2026-09-01T04:01:57.104Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}