balderdashy/sails · warning
Cannot read package.json in the current directory (CWD)
Error message
Cannot read package.json in the current directory (CWD)
What it means
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.
Source
Thrown at errors/warn.js:38
incompatibleLocalSails: function(requiredVersion, localVersion) {
log.warn('Trying to lift app using a local copy of `sails`');
log.warn('(located in ' + nodepath.resolve(process.cwd(), 'node_modules/sails') + ')');
log.warn();
log.warn('But the package.json in the current directory indicates a dependency');
log.warn('on Sails `' + requiredVersion + '`, and the locally installed Sails is `' + localVersion + '`!');
log.warn();
log.warn('If you run into compatibility issues, try installing ' + requiredVersion + ' locally:');
log.warn(' $ npm install sails@' + requiredVersion);
log.warn();
log.blank();
},
// Verbose-only warnings:
noPackageJSON: function() {
log.warn('Cannot read package.json in the current directory (' + process.cwd() + ')');
log.warn('Are you sure this is a Sails app?');
log.warn();
},
notSailsApp: function() {
log.warn('The package.json in the current directory does not list Sails as a dependency...');
log.warn('Are you sure `' + process.cwd() + '` is a Sails app?');
log.warn();
},
badLocalDependency: function(pathToLocalSails, requiredVersion) {
log.warn(
'The local Sails dependency installed at `' + pathToLocalSails + '` ' +
'has a corrupted, missing, or un-parsable package.json file.'
);
log.warn('You may consider running:');
log.warn('rm -rf ' + pathToLocalSails + ' && npm install sails@' + requiredVersion);
log.warn();View on GitHub (pinned to 7b76422cc2)
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.
Example fix
// before (terminal) /home/me/project/server-files$ sails lift // after cd /home/me/project sails lift
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
const path = require('path');
if (!fs.existsSync(path.join(process.cwd(), 'package.json'))) {
throw new Error('No package.json in CWD; cd to your Sails app root before running sails lift');
} Prevention
- 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).
When it happens
Trigger: 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().
Common situations: 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.
Related errors
- But the package.json in the current directory indicates a de
- Are you sure this is a Sails app?
- The package.json in the current directory does not list Sail
- Are you sure `${process.cwd()}` is a Sails app?
- Cannot call res.render() - `req._sails.renderView` was not a
AI-assisted analysis of balderdashy/sails@7b76422cc2 (2026-09-01).
Data as JSON: /api/errors/357d12476398a24f.
Report an issue: GitHub.