From b9044595618c25e345b22f755ca6ad80f711963f Mon Sep 17 00:00:00 2001 From: Avital Oliver Date: Mon, 8 Apr 2013 07:04:33 -0700 Subject: [PATCH] Unbreak apps that reached a corrupted state due to #927 Previously to fixing #927, if you had a 'node_modules' directory anywhere up the directory tree from your app and you had a package in your app using NPM, all calls to 'npm' ran against the 'node_modules' directory it found, so neither 'node_modules' nor 'npm-shrinkwrap.json' would be created within your package's .npm directory. The fix to #927 ensured that 'node_modules' was first created within '.npm' but people who had already run 0.6.0 were still in a corrupted state. --- tools/meteor_npm.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/meteor_npm.js b/tools/meteor_npm.js index 42cf2df36f2..3284db4dc47 100644 --- a/tools/meteor_npm.js +++ b/tools/meteor_npm.js @@ -62,6 +62,19 @@ _.extend(exports, { var newPackageNpmDir = packageNpmDir + '-new-' + self._randomToken(); try { + // v0.6.0 had a bug that could cause .npm directories to be + // created without npm-shrinkwrap.json + // (https://github.com/meteor/meteor/pull/927). Running your app + // in that state causes consistent "Corrupted .npm directory" + // errors. + // + // If you've reached that state, delete the empty directory and + // proceed. + if (fs.existsSync(packageNpmDir) && + !fs.existsSync(path.join(packageNpmDir, 'npm-shrinkwrap.json'))) { + files.rm_recursive(packageNpmDir); + } + if (fs.existsSync(packageNpmDir)) { // we already nave a .npm directory. update it appropriately with some ceremony involving: // `npm install`, `npm install name@version`, `npm shrinkwrap`