2015-12-29 279 views
0

我是NodeJS的新手,剛剛克隆了代碼並檢查了我的node_modules文件夾,它已經安裝了將近100個依賴項。這是我的目錄結構npm安裝,安裝軟件包甚至沒有列在我的package.json文件中

node_modules/ 
├── accepts 
├── after 
│   └── test 
├── ansi-regex 
├── ansi-styles 
├── arraybuffer.slice 
│   └── test 
├── array-flatten 
├── asn1 
│   ├── lib 
│   │   └── ber 
│   └── tst 
│    └── ber 
├── assert-plus 
├── async 
│   ├── lib 
│   └── support 
├── aws-sign2 
├── backo2 
│   └── test 
├── base64-arraybuffer 
│   ├── lib 
│   └── test 
├── base64id 
│   └── lib 
├── base64-url 
├── benchmark 
│   ├── doc 
│   └── test 
├── better-assert 
├── bindings 
├── bl 
│   ├── node_modules 
│   │   └── readable-stream 
│   │    ├── doc 
│   │    │   └── wg-meetings 
│   │    └── lib 
│   └── test 
├── blob 
│   └── test 
├── bluebird 
│   └── js 
│    ├── browser 
│    └── main 
├── body-parser 
│   └── lib 
│    └── types 
├── boom 
│   ├── images 
│   ├── lib 
│   └── test 
├── bson 
│   ├── alternate_parsers 
│   ├── browser_build 
│   ├── lib 
│   │   └── bson 
│   │    └── parser 
│   └── tools 
├── bufferutil 
│   ├── build 
│   │   └── Release 
│   │    └── obj.target 
│   │     └── bufferutil 
│   │      └── src 
│   └── src 
├── bytes 
├── callsite 
├── caseless 
├── chalk 
├── combined-stream 
│   └── lib 
├── commander 
├── component-bind 
├── component-emitter 
├── component-inherit 
│   └── test 
├── connect-mongodb-session 
│   └── test 
├── content-disposition 
├── content-type 
├── cookie 
├── cookie-parser 
├── cookie-signature 
├── core-util-is 
│   └── lib 
├── crc 
│   └── lib 
├── cryptiles 
│   ├── lib 
│   └── test 
├── dashdash 
│   └── lib 
├── debug 
├── delayed-stream 
│   └── lib 
├── depd 
│   └── lib 
│    ├── browser 
│    └── compat 
├── destroy 
├── ecc-jsbn 
│   └── lib 
├── ee-first 
├── engine.io 
│   ├── lib 
│   │   └── transports 
│   └── node_modules 
│    ├── debug 
│    └── ms 
├── engine.io-client 
│   ├── lib 
│   │   └── transports 
│   └── node_modules 
│    ├── debug 
│    ├── ms 
│    └── parseuri 
├── engine.io-parser 
│   └── lib 
├── es6-promise 
│   ├── dist 
│   └── lib 
│    └── es6-promise 
│     └── promise 
├── escape-html 
├── escape-string-regexp 
├── etag 
├── express 
│   ├── lib 
│   │   ├── middleware 
│   │   └── router 
│   └── node_modules 
│    ├── cookie 
│    ├── depd 
│    │   └── lib 
│    │    └── compat 
│    └── qs 
│     ├── lib 
│     └── test 
├── express-session 
│   ├── node_modules 
│   │   └── cookie 
│   └── session 
├── extend 
├── extsprintf 
│   ├── examples 
│   └── lib 
├── finalhandler 
├── flushwritable 
│   ├── lib 
│   └── test 
├── forever-agent 
├── form-data 
│   ├── lib 
│   └── node_modules 
│    └── async 
│     ├── dist 
│     └── lib 
├── forwarded 
├── fresh 
├── generate-function 
├── generate-object-property 
├── global 
│   └── test 
├── graceful-readlink 
├── gridfs-stream 
│   ├── lib 
│   └── test 
│    └── fixtures 
├── har-validator 
│   ├── bin 
│   └── lib 
│    └── schemas 
├── has-ansi 
├── has-binary 
│   └── fixtures 
├── has-binary-data 
│   └── fixtures 
├── has-cors 
├── hawk 
│   ├── dist 
│   ├── example 
│   ├── images 
│   ├── lib 
│   └── test 
├── hoek 
│   ├── images 
│   ├── lib 
│   └── test 
│    └── modules 
├── hooks-fixed 
├── http-errors 
├── http-signature 
│   └── lib 
├── iconv-lite 
│   ├── encodings 
│   │   └── tables 
│   └── lib 
├── indexof 
├── inherits 
├── ipaddr.js 
│   ├── lib 
│   ├── src 
│   └── test 
├── isarray 
│   └── build 
├── is-my-json-valid 
│   └── test 
│    ├── fixtures 
│    └── json-schema-draft4 
├── is-property 
├── isstream 
├── is-typedarray 
├── jodid25519 
│   └── lib 
├── jsbn 
├── json3 
│   ├── coverage 
│   │   └── lcov-report 
│   │    └── lib 
│   └── lib 
├── jsonpointer 
├── json-schema 
│   ├── draft-00 
│   ├── draft-01 
│   ├── draft-02 
│   ├── draft-03 
│   │   └── examples 
│   ├── draft-04 
│   ├── lib 
│   └── test 
├── json-stringify-safe 
│   └── test 
├── jsprim 
│   └── lib 
├── kareem 
│   └── test 
├── lodash 
│   ├── array 
│   ├── chain 
│   ├── collection 
│   ├── date 
│   ├── function 
│   ├── internal 
│   ├── lang 
│   ├── math 
│   ├── number 
│   ├── object 
│   ├── string 
│   └── utility 
├── media-typer 
├── merge-descriptors 
├── methods 
├── mime 
│   └── build 
├── mime-db 
├── mime-types 
├── moment 
│   ├── locale 
│   └── min 
├── mongodb 
│   ├── lib 
│   │   ├── bulk 
│   │   ├── gridfs 
│   │   └── gridfs-stream 
│   └── test_boot 
│    └── data 
│     └── diagnostic.data 
├── mongodb-core 
│   └── lib 
│    ├── auth 
│    ├── connection 
│    ├── tools 
│    ├── topologies 
│    │   └── strategies 
│    └── wireprotocol 
├── mongoose 
│   ├── examples 
│   │   ├── aggregate 
│   │   ├── express 
│   │   │   └── connection-sharing 
│   │   ├── geospatial 
│   │   ├── globalschemas 
│   │   ├── lean 
│   │   ├── mapreduce 
│   │   ├── population 
│   │   ├── promises 
│   │   ├── querybuilder 
│   │   ├── replicasets 
│   │   ├── schema 
│   │   │   └── storing-schemas-as-json 
│   │   └── statics 
│   ├── lib 
│   │   ├── drivers 
│   │   │   ├── browser 
│   │   │   └── node-mongodb-native 
│   │   ├── error 
│   │   ├── schema 
│   │   │   └── operators 
│   │   ├── services 
│   │   └── types 
│   └── node_modules 
│    ├── async 
│    │   └── lib 
│    └── bson 
│     ├── alternate_parsers 
│     ├── browser_build 
│     ├── lib 
│     │   └── bson 
│     │    └── parser 
│     └── tools 
├── mpath 
│   ├── lib 
│   └── test 
├── mpromise 
│   ├── lib 
│   └── test 
├── mquery 
│   ├── lib 
│   │   └── collection 
│   └── test 
│    └── collection 
├── ms 
├── muri 
│   ├── lib 
│   └── test 
├── nan 
│   ├── doc 
│   └── tools 
├── negotiator 
│   └── lib 
├── node-gcm 
│   ├── lib 
│   └── node_modules 
│    └── debug 
│     └── lib 
├── node-uuid 
│   ├── benchmark 
│   ├── bin 
│   └── test 
├── oauth 
│   ├── examples 
│   │   └── express-gdata 
│   │    └── views 
│   ├── lib 
│   └── tests 
├── oauth-sign 
├── object-component 
│   └── test 
├── object-keys 
├── on-finished 
├── on-headers 
├── options 
│   └── lib 
├── parsejson 
├── parseqs 
├── parseuri 
├── parseurl 
├── passport 
│   └── lib 
│    ├── errors 
│    ├── framework 
│    ├── http 
│    ├── middleware 
│    └── strategies 
├── passport-facebook 
│   └── lib 
│    └── errors 
├── passport-local 
│   └── lib 
├── passport-oauth2 
│   └── lib 
│    └── errors 
├── passport-strategy 
│   └── lib 
├── password-hash 
│   ├── bin 
│   ├── lib 
│   └── test 
├── path-to-regexp 
├── pause 
├── pinkie 
├── pinkie-promise 
├── process-nextick-args 
├── proxy-addr 
├── qs 
│   ├── dist 
│   ├── lib 
│   └── test 
├── random-key 
├── range-parser 
├── raw-body 
├── readable-stream 
│   └── lib 
├── regexp-clone 
│   └── test 
├── request 
│   └── lib 
├── send 
│   └── node_modules 
│    └── depd 
│     └── lib 
│      └── compat 
├── serve-static 
├── sliced 
│   ├── lib 
│   └── test 
├── sntp 
│   ├── examples 
│   ├── lib 
│   └── test 
├── socket.io 
│   ├── lib 
│   └── node_modules 
│    ├── debug 
│    └── ms 
├── socket.io-adapter 
│   └── node_modules 
│    ├── debug 
│    ├── ms 
│    └── socket.io-parser 
│     ├── bench 
│     └── node_modules 
│      └── debug 
│       └── lib 
├── socket.io-client 
│   ├── lib 
│   └── node_modules 
│    └── debug 
│     └── lib 
├── socket.io-parser 
│   ├── bench 
│   └── node_modules 
│    └── debug 
│     └── lib 
├── sshpk 
│   ├── bin 
│   ├── lib 
│   │   └── formats 
│   └── node_modules 
│    └── assert-plus 
├── statuses 
├── string_decoder 
├── stringstream 
├── strip-ansi 
├── supports-color 
├── to-array 
├── tough-cookie 
│   └── lib 
├── tunnel-agent 
├── tweetnacl 
├── type-is 
├── uid2 
├── uid-safe 
├── ultron 
├── unpipe 
├── utf8 
│   └── tests 
├── utf-8-validate 
│   ├── build 
│   │   └── Release 
│   │    └── obj.target 
│   │     └── validation 
│   │      └── src 
│   └── src 
├── util-deprecate 
├── utils-merge 
├── vary 
├── verror 
│   ├── examples 
│   ├── lib 
│   └── tests 
├── ws 
│   └── lib 
├── xmlhttprequest 
│   ├── example 
│   ├── lib 
│   └── tests 
└── xtend 

,這我的package.json

{ 
    "name": "my-api", 
    "version": "1.0.0", 
    "description": "", 
    "main": "app.js", 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "author": "", 
    "license": "ISC", 
    "dependencies": { 
    "async": "^0.9.0", 
    "body-parser": "^1.12.0", 
    "cookie-parser": "^1.3.4", 
    "express": "latest", 
    "express-session": "^1.11.1", 
    "gridfs-stream": "latest", 
    "moment": "^2.10.6", 
    "mongoose": "latest", 
    "node-gcm": "latest", 
    "passport": "^0.2.1", 
    "passport-facebook": "latest", 
    "passport-local": "latest", 
    "password-hash": "^1.2.2", 
    "random-key": "^0.3.2", 
    "socket.io": "^1.3.5", 
    "connect-mongodb-session" : "latest" 
    } 
} 

有什麼不對呢?我的朋友有同樣的項目,但在他的node_modules中只創建了package.json中提到的文件夾。

+0

這些可能只是依賴關係 –

+0

是的,但這是一個新功能嗎?因爲幾天前我在我的朋友筆記本電腦上做了同樣的事情,並且它工作正常......這是我第一次看到這個 –

+0

自從npm v3以來,它是新的https://github.com/npm/npm/blob/主/ CHANGELOG.md#平板平面 - 平面形 – SlashmanX

回答

1

他們依賴的依賴 -

例子:

您對快遞的依賴。
這反過來,對several packages 依賴每個這些有依賴,對等...

當你npm install整個依賴圖需要下載到您的node_modules文件夾

一個很好的itneractive工具用於可視化快遞的依賴關係圖是http://npm.anvaka.com/#/view/2d/express