Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't fail on false mkdirp failures

  • Loading branch information...
commit f6dc0528480fa65d792c765c59a2a94cd6d43770 1 parent 3e7438b
@isaacs isaacs authored
Showing with 18 additions and 1 deletion.
  1. +18 −1 lib/npm.js
View
19 lib/npm.js
@@ -26,10 +26,27 @@ var EventEmitter = require("events").EventEmitter
, semver = require("semver")
, findPrefix = require("./utils/find-prefix.js")
, getUid = require("uid-number")
- , mkdir = require("mkdirp")
+ , mkdirp = require("mkdirp")
, slide = require("slide")
, chain = slide.chain
+// /usr/local is often a read-only fs, which is not
+// well handled by node or mkdirp. Just double-check
+// in the case of errors when making the prefix dirs.
+function mkdir (p, cb) {
+ mkdirp(p, function (er, made) {
+ // it could be that we couldn't create it, because it
+ // already exists, and is on a read-only fs.
+ if (er) {
+ return fs.stat(p, function (er2, st) {
+ if (er2 || !st.isDirectory()) return cb(er)
+ return cb(null, made)
+ })
+ }
+ return cb(er, made)
+ })
+}
+
npm.commands = {}
npm.ELIFECYCLE = {}
npm.E404 = {}
Please sign in to comment.
Something went wrong with that request. Please try again.