Skip to content

Instantly share code, notes, and snippets.

@sbellone
sbellone / node_cache_test.js
Created September 3, 2014 13:33
Install 'winston' 0.6.2, require it, then clean all module cache, install 'winston' 0.7.2 and require it. It will fail because 'winston' 0.6.x uses 'async' 0.1 whereas 'winston' 0.7.x uses 'async' 0.2, which has changed its main file. Since the main file name is kept in cache in the variable packageMainCache (in module.js), the module will not b…
var npm = require('npm');
npm.load({}, function (er) {
if (er) console.log(er)
npm.commands.install(["winston@0.6.2"], function (er, data) {
if (er) {
console.log("npm install failed: " + er);
}
else {
var winston = require('winston');