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

  1. Install the version required by package.json: npm install sails@<requiredVersion> --save.
  2. Run npm install to resync node_modules with package.json.
  3. Delete node_modules/sails and package-lock.json, then reinstall.
  4. 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

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


AI-assisted analysis of balderdashy/sails@7b76422cc2 (2026-09-01). Data as JSON: /api/errors/d1b3c2a9f1232195. Report an issue: GitHub.