{"record":{"id":"e22dc172b7ea60e0","repo":"balderdashy/sails","slug":"the-local-sails-dependency-installed-at-pathtol","errorCode":null,"errorMessage":"The local Sails dependency installed at `${pathToLocalSails}` has a corrupted, missing, or un-parsable package.json file.","messagePattern":"The local Sails dependency installed at `(.+?)` has a corrupted, missing, or un-parsable package\\.json file\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"errors/warn.js","lineNumber":50,"sourceCode":"\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();\n  }\n};\n","sourceCodeStart":32,"sourceCodeEnd":59,"githubUrl":"https://github.com/balderdashy/sails/blob/7b76422cc27823df033572bdda5c4910a68b697f/errors/warn.js#L32-L59","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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`)."],"exampleFix":"// before (terminal, broken install)\nsails lift\n// after\nrm -rf node_modules/sails && npm install sails@^1.5.0\nsails lift","handlingStrategy":"validation","validationCode":"const fs = require('fs');\ntry {\n  JSON.parse(fs.readFileSync('./node_modules/sails/package.json', 'utf8'));\n} catch (e) {\n  console.error('node_modules/sails/package.json unreadable; run: rm -rf node_modules/sails && npm install sails');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"// When programmatic recovery is needed (sailsctl-like scripts):\ntry {\n  const sailsPkg = JSON.parse(fs.readFileSync(localSailsPath + '/package.json', 'utf8'));\n  if (!sailsPkg.version) throw new Error('sails package.json has no version');\n} catch (err) {\n  execSync(`rm -rf ${localSailsPath} && npm install sails@${requiredVersion}`, { stdio: 'inherit' });\n}","preventionTips":["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."],"tags":["sails","node-modules","corrupted-package-json","npm-install"],"backgroundTag":"corrupted-package-json","analyzedSha":"7b76422cc27823df033572bdda5c4910a68b697f","analyzedAt":"2026-09-01T04:01:57.104Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}