when "npm install" is used with package.json, module gets installed under itself #3958

Open
cowboy opened this Issue Oct 1, 2013 · 4 comments

Projects

None yet

4 participants

@cowboy
cowboy commented Oct 1, 2013

Yes, the error appears to be very specific, tested in node v0.10.19 and npm@1.3.11. Also note that I simplified my package.json file temporarily to help with troubleshooting.

My environment:

$ npm --version
1.3.11

$ pwd
/Users/cowboy/repos/gruntjs/grunt

$ cat package.json
{
  "name": "grunt",
  "version": "0.4.2-0",
  "repository": {
    "type": "git",
    "url": "git://github.com/gruntjs/grunt.git"
  },
  "devDependencies": {
    "grunt-contrib-copy": "*"
  }
}

In this example, both npm install behaviors work as expected.

$ rm -rf node_modules/

$ npm install grunt
npm WARN install Refusing to install grunt as a dependency of itself

$ npm install --silent grunt-contrib-copy
grunt-contrib-copy@0.4.1 node_modules/grunt-contrib-copy

$ tree -L 1 node_modules/
node_modules/
└── grunt-contrib-copy

1 directory, 0 files

Running npm install with a package.json file doesn't work as expected. In case it helps debug, note that grunt is both a devDependency and a peerDependency of grunt-contrib-copy. See that project's package.json.

$ rm -rf node_modules/

$ npm install --silent
grunt@0.4.1 node_modules/grunt
├── which@1.0.5
├── dateformat@1.0.2-1.2.3
├── eventemitter2@0.4.13
├── colors@0.6.2
├── hooker@0.2.3
├── async@0.1.22
├── coffee-script@1.3.3
├── underscore.string@2.2.1
├── iconv-lite@0.2.11
├── lodash@0.9.2
├── findup-sync@0.1.2 (lodash@1.0.1)
├── nopt@1.0.10 (abbrev@1.0.4)
├── rimraf@2.0.3 (graceful-fs@1.1.14)
├── minimatch@0.2.12 (sigmund@1.0.0, lru-cache@2.3.1)
├── glob@3.1.21 (inherits@1.0.0, graceful-fs@1.2.3)
└── js-yaml@2.0.5 (esprima@1.0.4, argparse@0.1.15)

grunt-contrib-copy@0.4.1 node_modules/grunt-contrib-copy

$ tree -L 1 node_modules/
node_modules/
├── grunt
└── grunt-contrib-copy

2 directories, 0 files
@cowboy cowboy added a commit to gruntjs/grunt that referenced this issue Dec 18, 2013
@cowboy cowboy Work-around for npm/npm#3958.
* This should allow the build to pass again.
fab3255
@cowboy cowboy added a commit to gruntjs/grunt that referenced this issue Mar 6, 2014
@cowboy cowboy Reverting fix for npm/npm#3958. Closes gh-1046, gh-1077.
* This doesn't work when "npm install" is run as root.
* When devving grunt, the user should follow "npm install" with "npm uninstall grunt" to work around the npm/npm#3958 issue. This will be reflected in the docs.
1c06b40
@cowboy cowboy added a commit to gruntjs/grunt that referenced this issue Mar 6, 2014
@cowboy cowboy Reverting fix for npm/npm#3958. Closes gh-1046, gh-1077.
* This doesn't work when "npm install" is run as root.
* When devving grunt, the user should follow "npm install" with "npm uninstall grunt" to work around the npm/npm#3958 issue. This will be reflected in the docs.
abb6d09
@jmeas jmeas added a commit to jmeas/grunt that referenced this issue Mar 12, 2014
@cowboy @jmeas cowboy + jmeas Reverting fix for npm/npm#3958. Closes gh-1046, gh-1077.
* This doesn't work when "npm install" is run as root.
* When devving grunt, the user should follow "npm install" with "npm uninstall grunt" to work around the npm/npm#3958 issue. This will be reflected in the docs.
e4d7c1f
@jmeas jmeas added a commit to jmeas/grunt that referenced this issue Mar 12, 2014
@cowboy @jmeas cowboy + jmeas Reverting fix for npm/npm#3958. Closes gh-1046, gh-1077.
* This doesn't work when "npm install" is run as root.
* When devving grunt, the user should follow "npm install" with "npm uninstall grunt" to work around the npm/npm#3958 issue. This will be reflected in the docs.
e92b242
@othiym23 othiym23 added the bug label Oct 10, 2014
@smikes
Contributor
smikes commented Nov 19, 2014

I reproduced this behavior with 2.1.8, which is npm@latest. I suspect this one of the the issues that will magically go away when multi-stage install lands, so I will just tag @iarna as an FYI.

@othiym23
Contributor

Hey Ben, we've made a bunch of tweaks to peerDependencies over the last year, so if you could confirm whether this is still an issue, that would be awesome.

@cowboy
cowboy commented May 5, 2015

This is still happening.

$ npm --version
2.7.6

$ npm install
npm WARN peerDependencies The peer dependency grunt@~0.4.0 included from grunt-contrib-nodeunit will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency grunt@~0.4.2 included from grunt-jscs will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency grunt@~0.4.0 included from grunt-contrib-jshint will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency grunt@~0.4.0 included from grunt-contrib-watch will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
dateformat@1.0.2-1.2.3 node_modules/dateformat

eventemitter2@0.4.14 node_modules/eventemitter2

rimraf@2.2.8 node_modules/rimraf

exit@0.1.2 node_modules/exit

semver@2.1.0 node_modules/semver

nopt@1.0.10 node_modules/nopt
└── abbrev@1.0.5

shelljs@0.2.6 node_modules/shelljs

temporary@0.0.8 node_modules/temporary
└── package@1.0.1

minimatch@0.2.14 node_modules/minimatch
├── sigmund@1.0.0
└── lru-cache@2.6.2

glob@3.1.21 node_modules/glob
├── inherits@1.0.0
└── graceful-fs@1.2.3

difflet@0.2.6 node_modules/difflet
├── deep-is@0.1.3
├── charm@0.1.2
└── traverse@0.6.6

coffee-script@1.3.3 node_modules/coffee-script

grunt-legacy-util@0.2.0 node_modules/grunt-legacy-util
├── which@1.0.9
├── getobject@0.1.0
├── async@0.1.22
├── hooker@0.2.3
├── lodash@0.9.2
└── underscore.string@2.2.1

iconv-lite@0.2.11 node_modules/iconv-lite

findup-sync@0.1.3 node_modules/findup-sync
├── glob@3.2.11 (inherits@2.0.1, minimatch@0.3.0)
└── lodash@2.4.2

grunt-legacy-log@0.1.1 node_modules/grunt-legacy-log
├── colors@0.6.2
├── hooker@0.2.3
├── underscore.string@2.3.3
└── lodash@2.4.2

js-yaml@2.0.5 node_modules/js-yaml
├── argparse@0.1.16 (underscore.string@2.4.0, underscore@1.7.0)
└── esprima@1.0.4

grunt-contrib-watch@0.5.3 node_modules/grunt-contrib-watch
├── tiny-lr@0.0.4 (debug@0.7.4, faye-websocket@0.4.4, noptify@0.0.3, qs@0.5.6)
└── gaze@0.4.3 (globule@0.1.0)

grunt@0.4.5 node_modules/grunt
├── which@1.0.9
├── getobject@0.1.0
├── colors@0.6.2
├── async@0.1.22
├── hooker@0.2.3
├── lodash@0.9.2
└── underscore.string@2.2.1

grunt-contrib-jshint@0.6.5 node_modules/grunt-contrib-jshint
└── jshint@2.1.11 (console-browserify@0.1.6, cli@0.4.5, underscore@1.4.4, shelljs@0.1.4)

grunt-jscs@1.5.0 node_modules/grunt-jscs
├── vow@0.4.9
├── hooker@0.2.3
├── lodash@2.4.2
└── jscs@1.11.3 (strip-json-comments@1.0.2, supports-color@1.2.1, cli-table@0.3.1, commander@2.6.0, estraverse@1.9.3, colors@1.0.3, vow-fs@0.3.4, glob@4.3.5, lodash.assign@3.0.0, minimatch@2.0.7, esprima-harmony-jscs@1.1.0-tolerate-import, prompt@0.2.14, esprima@1.2.5, xmlbuilder@2.5.2)

grunt-contrib-nodeunit@0.4.1 node_modules/grunt-contrib-nodeunit
├── hooker@0.2.3
└── nodeunit@0.9.1 (tap@0.7.1)

$ grunt --version
grunt-cli v0.1.13
grunt v0.4.5

$ rm -rf node_modules/grunt

$ grunt --version
grunt-cli v0.1.13
grunt v0.4.6-0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment