Ich schrieb eine einfache Anwendung mit Knoten. Es kommt auf Express, Mongodb und Mungo (einfach) an. Also, habe ich eine Datei package.json
und setzen diese in ihm genannt:Wie schreibe ich eine package.json Datei, so dass alle Abhängigkeiten mit "npm install" heruntergeladen werden
{
"name": "booking-dojo",
"description": "Booking dojo app",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "3.x",
"mongodb": "*",
"mongoose": "*"
}
}
Ich lief dann npm install
, npm die Module und ihre Abhängigkeiten zu installieren, zu erwarten. Das Ergebnis war enttäuschend:
[email protected] /home/merc/Synced/Development/Bookings/app/server
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
├── [email protected]
└── [email protected]
ich damit bin verwirrt, wie ich dass express
Bedürfnisse kennen jade
(und vieles mehr) und mongoose
Bedürfnisse mongodb
.
Wenn ich in node_modules/jade
gehen und laufen npm install
, das Ergebnis aus dem Hauptbaum ist sehr unterschiedlich:
[email protected] /home/merc/Synced/Development/Bookings/app/server
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └─┬ [email protected]
│ └─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
├── [email protected]
└── [email protected]
So express
hat gewachsen viel. Es sieht aus wie npm install
lädt nur einige der Abhängigkeiten der Untermodule.
Kann jemand bitte etwas Licht darauf werfen? Warum fehlen einige Abhängigkeiten? Mache ich etwas falsch? (wahrscheinlich)
Danke!
Merc.
Eine andere Sache zu beachten ist, dass, wenn ein Paket auf einem Modul abhängt, die bis weiter in der Abhängigkeitskette gelöst werden kann, wird es. Zum Beispiel, da du 'mongodb' in deinem package.json hast, muss Mongoose nicht sein eigenes' mongodb' installieren. –
Brandon, das * ist * die Antwort. Ich habe es gerade erst herausgefunden. Grundsätzlich wird MongoDb nicht unter Mongoose installiert, da es weiter oben aufgelöst wird. Da dies * die tatsächliche Antwort ist, kannst du sie bitte als richtige Antwort und nicht als Kommentar hinzufügen, damit ich sie akzeptieren kann? – Merc
@Peter Guter Punkt, Anwendungen * generiert * per Express wird jedoch als Abhängigkeit BTW ausdrücken. Meine Frage, "warum fehlen einige Abhängigkeiten?", Hat die einfache Antwort (von Brandon): "Sie fehlen, weil sie weiter oben im Abhängigkeitsbaum aufgelöst sind". Vielen Dank! – Merc