NPM notes

A node project has its source files, and its modules. The modules take up a lot of space, hence, we have package.json to let the project know which modules is required by the source code. Hence, when you are sending the project around, you can remove the modules and just send the source code.

When the receiver gets the project, all they see is the package.json and the source. A package.json file in your node directory is to let you know which packages to install when you want to run it on a server.

npm install

then it’ll start downloading and installing the modules:

Rickys-MacBook-Pro:MM-CRM rickytsao$ npm install
npm WARN package.json node-api@ No description
npm WARN package.json node-api@ No repository field.
npm WARN package.json node-api@ No README data
npm WARN package.json node-api@ No license field.
npm WARN deprecated jsonwebtoken@1.3.0: Critical vulnerability fix in v5.0.0. See
npm WARN deprecated jws@0.2.6: Security update: Versions below 3.0.0 are deprecated.
> bson@0.2.22 install /Users/rickytsao/Documents/Angular/MM-CRM/node_modules/mongoose/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)

CXX(target) Release/
SOLINK_MODULE(target) Release/bson.node
SOLINK_MODULE(target) Release/bson.node: Finished

> kerberos@0.0.11 install /Users/rickytsao/Documents/Angular/MM-CRM/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)

CXX(target) Release/
CXX(target) Release/

morgan@1.5.3 node_modules/morgan
├── basic-auth@1.0.3
└── on-finished@2.2.1 (ee-first@1.1.0)

jsonwebtoken@1.3.0 node_modules/jsonwebtoken
└── jws@0.2.6 (jwa@0.0.1, base64url@0.0.6)

body-parser@1.9.3 node_modules/body-parser
├── bytes@1.0.0
└── type-is@1.5.7 (mime-types@2.0.14)

express@4.10.8 node_modules/express
├── merge-descriptors@0.0.2
└── accepts@1.1.4 (negotiator@0.4.9, mime-types@2.0.14)

mongoose@3.8.34 node_modules/mongoose
├── regexp-clone@0.0.1
└── mongodb@1.4.38 (readable-stream@2.0.2, bson@0.2.22, kerberos@0.0.11)

This will create the node_modules directory (if one doesn’t exist yet), and will download the modules to that directory. Then the project will work.