Node.js には、標準で assert モジュールが用意されています。
var assert = require('assert');
var count = 0;
assert(count > 0, 'count should be positive');
console オブジェクトには assert() メソッドが用意されており、こちらは何もモジュールをインポートしなくても使用できます。
console.assert(count > 0, 'count should be positive');