Node.js Development Guide - Book Notes
Chapter 3
Single Loading:
require does not load modules repeatedly. No matter how many times require is called, the module obtained is always the same one.
Overriding exports:
When encapsulating an object into a module, using exports.Hello = Hello requires require(‘./singleobject’).Hello to obtain the object. This can be simplified as follows: module.exports = Hello; Then you can directly obtain the object: var Hello = require(‘./hello’); hello = new Hello();
Creating Global Links:
npm link express; This allows you to use the globally installed express in the current directory.
Use npm init to interactively initialize a standard package.json;
Publish a package: npm publish;
After modifying the version field in the json file, republish to update the version;
Unpublish: npm unpublish;