balderdashy/sails · warning
The local Sails dependency installed at `${pathToLocalSails}
Error message
The local Sails dependency installed at `${pathToLocalSails}` has a corrupted, missing, or un-parsable package.json file. What it means
First line of the `badLocalDependency` warning in errors/warn.js:50. The local Sails copy installed at pathToLocalSails (typically node_modules/sails) exists but its package.json is corrupted, missing, or unparsable, so Sails cannot read its version. Usually a symptom of a broken or interrupted npm install.
Source
Thrown at errors/warn.js:50
// 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
- Run the suggested fix: `rm -rf node_modules/sails && npm install sails@<requiredVersion>`.
- If problems persist, wipe everything: `rm -rf node_modules package-lock.json && npm install`.
- Check disk space and re-run the install without interruption; verify with `node -e "require('./node_modules/sails/package.json')"`.
- Restore node_modules from a clean CI cache or reinstall via the lockfile (`npm ci`).
Example fix
// before (terminal, broken install) sails lift // after rm -rf node_modules/sails && npm install sails@^1.5.0 sails lift
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
try {
JSON.parse(fs.readFileSync('./node_modules/sails/package.json', 'utf8'));
} catch (e) {
console.error('node_modules/sails/package.json unreadable; run: rm -rf node_modules/sails && npm install sails');
process.exit(1);
} Try / catch
// When programmatic recovery is needed (sailsctl-like scripts):
try {
const sailsPkg = JSON.parse(fs.readFileSync(localSailsPath + '/package.json', 'utf8'));
if (!sailsPkg.version) throw new Error('sails package.json has no version');
} catch (err) {
execSync(`rm -rf ${localSailsPath} && npm install sails@${requiredVersion}`, { stdio: 'inherit' });
} Prevention
- Don't kill npm installs midway; ensure enough disk space before installing.
- Prefer `npm ci` in CI for clean, atomic installs from the lockfile.
- Never manually edit or delete files inside node_modules.
- Re-verify installs after copying projects between machines or containers.
When it happens
Trigger: `sails lift` encounters node_modules/sails without a readable package.json — e.g. a partial install, disk-full during install, manual deletion inside node_modules, a git merge that clobbered files, or a symlinked/docked node_modules missing that file.
Common situations: Killed `npm install` mid-run; copying node_modules between machines/containers incompletely; antivirus or cleanup tools stripping files; low disk space during CI install steps.
Related errors
- If you run into compatibility issues, try installing REQUIRE
- $ npm install sails@REQUIRED_VERSION
- rm -rf ${pathToLocalSails} && npm install sails@${requiredVe
- Cannot call res.render() - `req._sails.renderView` was not a
- The 2-ary usage of `res.redirect()` is no longer supported i
AI-assisted analysis of balderdashy/sails@7b76422cc2 (2026-09-01).
Data as JSON: /api/errors/e22dc172b7ea60e0.
Report an issue: GitHub.