Ishan Khare
Ishan Khare

Reputation: 1767

npm doesn't work as expected

running npm install from any directory having package.json is not working for me at the moment. I've even tried it with some well known projects but the problem is same, so I guess it's not me messing up with my package.json.

So the problem is, npm install actually install about 241 modules in my local node_modules directory. While i have clearly listed just 3 in package.json. npm behaves abruptly installing the again and again, everytime I run it.

I previously worked with same code committed to git and npm install just resulted in 3 packages in my node_modules.

$ npm -v
3.8.1

$ node -v
v5.8.0

list of modules inside node_modules

$ ls node_modules/
ansi-regex        color-convert           extract-zip               gulp-concat        isstream                lodash.template          ordered-read-streams  request                supports-color
ansi-styles       combined-stream         extsprintf                gulp-util          jodid25519              lodash.templatesettings  os-homedir            resolve                throttleit
archy             commander               fancy-log                 gulplog            jsbn                    loud-rejection           parse-json            rimraf                 through2
array-differ      concat-map              fd-slicer                 har-validator      json-schema             lru-cache                path-exists           semver                 tildify
array-find-index  concat-stream           find-index                has-ansi           json-stringify-safe     map-obj                  path-is-absolute      sequencify             time-stamp
array-uniq        concat-with-sourcemaps  find-up                   has-gulplog        jsonpointer             meow                     path-type             sigmund                tough-cookie
asn1              core-util-is            findup-sync               hawk               jsprim                  mime-db                  pend                  signal-exit            trim-newlines
assert-plus       cryptiles               first-chunk-stream        hoek               liftoff                 mime-types               pify                  single-line-log        tunnel-agent
async             dashdash                flagged-respawn           home-path          load-json-file          minimatch                pinkie                sntp                   tweetnacl
aws-sign2         dateformat              forever-agent             hosted-git-info    lodash                  minimist                 pinkie-promise        source-map             typedarray
aws4              debug                   form-data                 http-signature     lodash._basecopy        mkdirp                   pretty-bytes          sparkles               unique-stream
balanced-match    decamelize              gaze                      indent-string      lodash._basetostring    ms                       pretty-hrtime         spdx-correct           user-home
beeper            deep-extend             generate-function         inflight           lodash._basevalues      multipipe                process-nextick-args  spdx-exceptions        util-deprecate
bl                defaults                generate-object-property  inherits           lodash._getnative       mv                       progress-stream       spdx-expression-parse  v8flags
boom              delayed-stream          get-stdin                 ini                lodash._isiterateecall  ncp                      pseudomap             spdx-license-ids       validate-npm-package-license
bower             deprecated              glob                      interpret          lodash._reescape        node-uuid                qs                    speedometer            verror
brace-expansion   duplexer2               glob-stream               is-arrayish        lodash._reevaluate      normalize-package-data   rc                    sshpk                  vinyl
builtin-modules   ecc-jsbn                glob-watcher              is-builtin-module  lodash._reinterpolate   nugget                   read-pkg              stream-consume         vinyl-fs
camelcase         electron-download       glob2base                 is-finite          lodash._root            number-is-nan            read-pkg-up           string_decoder         wrappy
camelcase-keys    electron-prebuilt       globule                   is-my-json-valid   lodash.escape           oauth-sign               readable-stream       stringstream           xtend
caseless          end-of-stream           glogg                     is-property        lodash.isarguments      object-assign            rechoir               strip-ansi             yallist
chalk             error-ex                graceful-fs               is-typedarray      lodash.isarray          object-keys              redent                strip-bom              yauzl
clone             escape-string-regexp    graceful-readlink         is-utf8            lodash.keys             once                     repeating             strip-indent
clone-stats       extend                  gulp                      isarray            lodash.restparam        orchestrator             replace-ext           strip-json-comments

package.json

{
  "name": "test",
  "version": "1.0.0",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "./node_modules/electron-prebuilt/dist/electron --harmony --enable-transparent-visuals ."
  },
  "author": "[email protected]",
  "license": "MIT",
  "dependencies": {
    "bower": "^1.7.7",
    "electron-prebuilt": "^0.36.7",
    "gulp": "^3.9.1",
    "gulp-concat": "^2.6.0"
  },
  "devDependencies": {},
  "description": ""
}

Upvotes: 0

Views: 765

Answers (1)

Maurits Rijk
Maurits Rijk

Reputation: 9985

This behaviour of npm has changed from version 2 to 3 and later: version 2 and older used subfolders. Since version 3 you get a flat package structure. So what you now see is all the transient dependencies that before were available as subfolders (node_modules) of your 4 dependencies.

However, the final behaviour should be exactly the same.

The rationale behind this can be found here.

Upvotes: 3

Related Questions