run npm rebuild only if cannot load native modules
Rebuilding native modules can be slow. This module attempts loading all native modules in
the dependency tree. If they fail, it runs npm rebuild
. This is useful when switching
between node versions or between operating systems with cached node_modules
directories.
$ npm-idempotent-rebuild
const npmIdempotentRebuild = require('npm-idempotent-rebuild')
npmIdempotentRebuild({dir: __dirname}, function (err, rebuilt) {
console.log(err, rebuilt ? : 'rebuilt node modules' : 'skipped rebuilding')
})
with jsig type annotation:
Rebuilds node_modules if necessary. Takes a Node.js-style callback with error, if any,
and rebuilt
, which is true if npm rebuild
was executed.
Options:
level
: String - one ofsilent
(default),info
, ordebug
dir
: String - the cwd for runningnpm rebuild
, defaults to current cwd.
$ npm install npm-idempotent-rebuild
From package root:
$ npm install
$ npm test
For debug information, set env var DEBUG=true
- jden jason@denizac.org
ISC. (c) MMXVI jden jason@denizac.org. See LICENSE.md