diff --git a/lib/register-db.js b/lib/register-db.js index db4caec..fa33b9d 100644 --- a/lib/register-db.js +++ b/lib/register-db.js @@ -40,10 +40,24 @@ function createDbRegister (pwd, _path, _require = require) { return dbs.get(name) } - const db = level( - path.resolve(dbPath, name), - {valueEncoding: 'json'} - ) + let db + try { + // Level pre-v8 + db = level( + path.resolve(dbPath, name), + {valueEncoding: 'json'} + ) + } catch (err) { + if (err instanceof TypeError && level.Level) { + // Level v8 + db = new level.Level( + path.resolve(dbPath, name), + {valueEncoding: 'json'} + ) + } else { + throw err + } + } dbs.set(name, db)