balderdashy/sails · warning
Trying to lift app using a local copy of `sails`
Error message
Trying to lift app using a local copy of `sails`
What it means
This is a compatibility warning from Sails' errors/warn.js (incompatibleLocalSails). When lifting an app, the globally-installed Sails detects a local copy in node_modules/sails whose version does not match the version range declared in the app's package.json. It warns that the local copy will be used and suggests installing the required version locally.
Source
Thrown at errors/warn.js:21
*/
var nodepath = require('path');
var CaptainsLog = require('captains-log');
// Once per process:
// Build logger using best-available information
// when this module is initially required.
var rconf = require('../lib/app/configuration/rc')();
var log = CaptainsLog(rconf.log);
/**
* Warnings
*/
module.exports = {
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?');View on GitHub (pinned to 7b76422cc2)
Solutions
- Install the version required by package.json: npm install sails@<requiredVersion> --save.
- Run npm install to resync node_modules with package.json.
- Delete node_modules/sails and package-lock.json, then reinstall.
- Invoke the local sails binary (npx sails lift) so global/local versions stay decoupled.
Example fix
// before (package.json)
"dependencies": { "sails": "^0.12.0" } // local copy is 1.0.0
// after
"dependencies": { "sails": "^1.0.0" }
// then: rm -rf node_modules && npm install Defensive patterns
Strategy: validation
Validate before calling
const pkg = require('./package.json');
const local = require('./node_modules/sails/package.json').version;
if (!require('semver').satisfies(local, pkg.dependencies.sails)) { console.error('sails version mismatch: need ' + pkg.dependencies.sails + ', have ' + local); process.exit(1); } Type guard
function sailsVersionMatches(depRange, localVersion) { try { return require('semver').satisfies(localVersion, depRange); } catch (e) { return false; } } Try / catch
try { require('sails').lift(config); } catch (e) { if (/incompatibleLocalSails|version/i.test(e.message)) { console.error('Install matching sails version locally'); process.exit(1); } throw e; } Prevention
- Always install sails as a project dependency, not just globally.
- Use npx sails lift to run the local binary.
- Reinstall node_modules after changing the sails version range.
- Pin sails versions in package.json and commit the lockfile.
When it happens
Trigger: Running `sails lift` (global CLI) in a project whose node_modules/sails version is incompatible with the package.json dependency range, e.g. package.json requires ~0.12.x but node_modules has 1.0.0.
Common situations: Upgrading Sails globally but not locally (or vice versa); stale node_modules after editing package.json without reinstalling; multiple projects on one machine with different Sails versions.
Related errors
- (located in NODE_MODULES_PATH/node_modules/sails)
- But the package.json in the current directory indicates a de
- on Sails `REQUIRED_VERSION`, and the locally installed Sails
- If you run into compatibility issues, try installing REQUIRE
- $ npm install sails@REQUIRED_VERSION
AI-assisted analysis of balderdashy/sails@7b76422cc2 (2026-09-01).
Data as JSON: /api/errors/d1b3c2a9f1232195.
Report an issue: GitHub.