Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Error out if an installation results in invalid peer dependencies. #3110

Closed
wants to merge 1 commit into from

3 participants

@domenic
Collaborator

Fixes #3079. Please also see #3102 and #3104. Maybe #3101 while you're at it.

Result is like this:

npm ERR! peerinvalid The package flatiron does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer flatiron-cli-config@0.1.3 wants flatiron@~0.1.9
npm ERR! peerinvalid Peer flatiron-cli-users@0.1.4 wants flatiron@~0.3.0

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "node" "C:\\Users\\Domenic\\Dropbox\\Programming\\GitHub\\npm\\cli.js" "install" "jitsu"
npm ERR! cwd C:\Users\Domenic\Dropbox\Programming\GitHub
npm ERR! node -v v0.8.18
npm ERR! npm -v 1.2.3
npm ERR! code EPEERINVALID
@isaacs
Owner

Landed on master.

@isaacs isaacs closed this
@isaacs
Owner

Thanks!

@isaacs isaacs reopened this
@isaacs isaacs closed this
@banacorn

still get this when installing something global, with node v0.8.19 and npm v1.2.10

blitz:rinde blitz$ sudo npm install -g recess
npm http GET https://registry.npmjs.org/recess
npm http 304 https://registry.npmjs.org/recess
npm http GET https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/underscore
npm http GET https://registry.npmjs.org/watch
npm http GET https://registry.npmjs.org/less
npm http 304 https://registry.npmjs.org/nopt
npm http 304 https://registry.npmjs.org/underscore
npm http 304 https://registry.npmjs.org/less
npm http 304 https://registry.npmjs.org/colors
npm http 304 https://registry.npmjs.org/watch
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/ycssmin
npm http 304 https://registry.npmjs.org/abbrev
npm http 304 https://registry.npmjs.org/ycssmin
/usr/local/bin/recess -> /usr/local/lib/node_modules/recess/bin/recess
npm ERR! peerinvalid The package flatiron does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer flatiron-cli-config@0.1.3 wants flatiron@~0.1.9
npm ERR! peerinvalid Peer flatiron-cli-users@0.1.1 wants flatiron@~0.1.9

npm ERR! System Darwin 12.2.1
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "recess"
npm ERR! cwd /Users/blitz/node/rinde
npm ERR! node -v v0.8.19
npm ERR! npm -v 1.2.10
npm ERR! code EPEERINVALID
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/blitz/node/rinde/npm-debug.log
npm ERR! not ok code 0
@domenic
Collaborator

@banacorn, did you read the error message? Your package has conflicting peer dependencies. This is a legitimate error with the recess package; you should file a bug there.

@banacorn

Yes, I've read the error message, but it doesn't seems to be a bug from recess, because I got the same problem while installing some other packages like express or coffee-script globally.

blitz:rinde blitz$ sudo npm install -g coffee-script
Password:
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script
/usr/local/bin/coffee -> /usr/local/lib/node_modules/coffee-script/bin/coffee
/usr/local/bin/cake -> /usr/local/lib/node_modules/coffee-script/bin/cake
npm ERR! peerinvalid The package flatiron does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer flatiron-cli-config@0.1.3 wants flatiron@~0.1.9
npm ERR! peerinvalid Peer flatiron-cli-users@0.1.1 wants flatiron@~0.1.9

npm ERR! System Darwin 12.2.1
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "coffee-script"
npm ERR! cwd /Users/blitz/node/rinde
npm ERR! node -v v0.8.19
npm ERR! npm -v 1.2.10
npm ERR! code EPEERINVALID
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/blitz/node/rinde/npm-debug.log
npm ERR! not ok code 0
@domenic
Collaborator

Ah. The problem is you have an old, broken version of jitsu installed globally, and it's detecting that failure at the end of the installation. Damn, that's a bug.

You should be able to fix this with npm uninstall jitsu -g then npm install jitsu -g.

@banacorn

Yes now it is fixed! thanks a lot :D

this is the last few lines of npm-debug.log and there's a scary undefined at the L712, hope this could help a bit:

699 verbose readInstalled returning underscore@1.4.4
700 verbose readInstalled returning watch@0.5.1
701 verbose readInstalled returning less@1.3.3
702 verbose readInstalled returning abbrev@1.0.4
703 verbose readInstalled returning ycssmin@1.0.1
704 verbose readInstalled returning cssom@0.2.5
705 verbose readInstalled returning mkdirp@0.3.4
706 verbose readInstalled returning debug@0.7.0
707 verbose readInstalled returning source-map@0.1.8
708 verbose readInstalled returning optimist@0.3.5
709 verbose readInstalled returning amdefine@0.0.4
710 verbose readInstalled returning wordwrap@0.0.2
711 verbose readInstalled returning bal-util@1.16.5
712 verbose readInstalled returning undefined
713 error peerinvalid The package flatiron does not satisfy its siblings' peerDependencies requirements!
713 error peerinvalid Peer flatiron-cli-config@0.1.3 wants flatiron@~0.1.9
713 error peerinvalid Peer flatiron-cli-users@0.1.1 wants flatiron@~0.1.9
714 error System Darwin 12.2.1
715 error command "node" "/usr/local/bin/npm" "install" "-g" "coffee-script"
716 error cwd /Users/blitz/node/rinde
717 error node -v v0.8.19
718 error npm -v 1.2.10
719 error code EPEERINVALID
720 verbose exit [ 1, true ]

Happy Chinese New Year :ghost:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 30, 2013
  1. @domenic
This page is out of date. Refresh to see the latest.
View
56 lib/install.js
@@ -61,6 +61,7 @@ install.completion = function (opts, cb) {
var npm = require("./npm.js")
, semver = require("semver")
, readJson = require("read-package-json")
+ , readInstalled = require("read-installed")
, log = require("npmlog")
, path = require("path")
, fs = require("graceful-fs")
@@ -77,12 +78,24 @@ function install (args, cb_) {
function cb (er, installed) {
if (er) return cb_(er)
- var tree = treeify(installed || [])
- , pretty = prettify(tree, installed).trim()
+ findPeerInvalid(where, function (er, problem) {
+ if (er) return cb_(er)
- if (pretty) console.log(pretty)
- if (er) return cb_(er)
- save(where, installed, tree, pretty, cb_)
+ if (problem) {
+ var peerInvalidError = new Error("The package " + problem.name +
+ " does not satisfy its siblings' peerDependencies requirements!")
+ peerInvalidError.code = "EPEERINVALID"
+ peerInvalidError.packageName = problem.name
+ peerInvalidError.peersDepending = problem.peersDepending
+ return cb(peerInvalidError)
+ }
+
+ var tree = treeify(installed || [])
+ , pretty = prettify(tree, installed).trim()
+
+ if (pretty) console.log(pretty)
+ save(where, installed, tree, pretty, cb_)
+ })
}
// the /path/to/node_modules/..
@@ -164,6 +177,39 @@ function install (args, cb_) {
})
}
+function findPeerInvalid (where, cb) {
+ readInstalled(where, function (er, data) {
+ if (er) return cb(er)
+
+ cb(null, findPeerInvalid_(data.dependencies))
+ })
+}
+
+function findPeerInvalid_ (packageMap) {
+ for (var packageName in packageMap) {
+ var pkg = packageMap[packageName]
+
+ if (pkg.peerInvalid) {
+ var peersDepending = {};
+ for (peerName in packageMap) {
+ var peer = packageMap[peerName]
+ if (peer.peerDependencies && peer.peerDependencies[packageName]) {
+ peersDepending[peer.name + "@" + peer.version] =
+ peer.peerDependencies[packageName]
+ }
+ }
+ return { name: pkg.name, peersDepending: peersDepending }
+ }
+
+ var peerInvalidDep = pkg.dependencies && findPeerInvalid_(pkg.dependencies)
+ if (peerInvalidDep) {
+ return peerInvalidDep
+ }
+ }
+
+ return null
+}
+
// reads dependencies for the package at "where". There are several cases,
// depending on our current state and the package's configuration:
//
View
8 lib/utils/error-handler.js
@@ -203,6 +203,14 @@ function errorHandler (er) {
].join("\n"))
break
+ case "EPEERINVALID":
+ var peerErrors = Object.keys(er.peersDepending).map(function (peer) {
+ return "Peer " + peer + " wants " + er.packageName + "@"
+ + er.peersDepending[peer]
+ })
+ log.error("peerinvalid", [er.message].concat(peerErrors).join("\n"))
+ break
+
case "ENOTSUP":
if (er.required) {
log.error("notsup", [er.message
View
1  test/packages/npm-test-peer-deps-invalid/README
@@ -1 +0,0 @@
-just an npm test
View
21 test/packages/npm-test-peer-deps-invalid/npm-ls.json
@@ -1,21 +0,0 @@
-{
- "npm-test-peer-deps-file": {
- "version": "1.2.3",
- "from": "https://raw.github.com/gist/3971128/3f6aa37b4fa1186c2f47da9b77dcc4ec496e3483/index.js",
- "resolved": "https://raw.github.com/gist/3971128/3f6aa37b4fa1186c2f47da9b77dcc4ec496e3483/index.js",
- "dependencies": {
- "opener": {
- "version": "1.3.0",
- "from": "opener@1.3.0"
- }
- }
- },
- "npm-test-peer-deps-file-invalid": {
- "version": "1.2.3",
- "from": "https://gist.github.com/raw/4303335/861f8d3213061826ab31591840c3cb0ac737f4fc/index.js",
- "resolved": "https://gist.github.com/raw/4303335/861f8d3213061826ab31591840c3cb0ac737f4fc/index.js"
- },
- "dict": {
- "peerInvalid": true
- }
-}
View
34 test/packages/npm-test-peer-deps-invalid/test.js
@@ -1,34 +0,0 @@
-var path = require("path")
-var assert = require("assert")
-
-process.env.npm_config_prefix = process.cwd()
-delete process.env.npm_config_global
-delete process.env.npm_config_depth
-
-var npm = process.env.npm_execpath
-
-require("child_process").execFile(process.execPath, [npm, "ls", "--json"], {
- env: process.env, cwd: process.cwd() },
- function (err, stdout, stderr) {
-
- var actual = JSON.parse(stdout).dependencies
- var expected = require("./npm-ls.json")
-
- // Delete the "problems" entry because it contains system-specific path info,
- // so we can't compare it accurately and thus have deleted it from
- // ./npm-ls.json.
- delete actual.dict.problems
-
- // It's undefined which peerDependency will get installed first, so
- // this will be either version 1.1.0 or version 1.0.0
- var dictVer = actual.dict.version
- delete actual.dict.version
- delete actual.dict.from
- delete actual.dict.resolved
- assert(dictVer === "1.1.0" || dictVer === "1.0.0")
- console.error(JSON.stringify(actual, null, 2))
- assert.deepEqual(actual, expected)
-
- assert.ok(err)
- assert(/peer invalid/.test(err.message))
-})
View
22 test/tap/peer-deps-invalid.js
@@ -0,0 +1,22 @@
+var fs = require("fs")
+var test = require("tap").test
+var rimraf = require("rimraf")
+var npm = require("../../")
+
+test("installing dependencies that having conflicting peerDependencies", function (t) {
+ t.plan(1)
+
+ rimraf.sync(__dirname + "/peer-deps-invalid/node_modules")
+ process.chdir(__dirname + "/peer-deps-invalid")
+
+ npm.load(function () {
+ npm.install(".", function (err) {
+ if (!err) {
+ t.fail("No error!")
+ return
+ }
+
+ t.equal(err.code, "EPEERINVALID")
+ })
+ })
+})
View
5 .../packages/npm-test-peer-deps-invalid/package.json → test/tap/peer-deps-invalid/package.json
@@ -1,12 +1,9 @@
{
"author": "Domenic Denicola <domenic@domenicdenicola.com> (http://domenicdenicola.com/)",
- "name": "npm-test-peer-deps-invalid",
+ "name": "peer-deps-invalid",
"version": "0.0.0",
"dependencies": {
"npm-test-peer-deps-file": "https://raw.github.com/gist/3971128/3f6aa37b4fa1186c2f47da9b77dcc4ec496e3483/index.js",
"npm-test-peer-deps-file-invalid": "https://gist.github.com/raw/4303335/861f8d3213061826ab31591840c3cb0ac737f4fc/index.js"
- },
- "scripts": {
- "test": "node test.js"
}
}
Something went wrong with that request. Please try again.