node.jsdatabaseleveldbleveldownlevelup

LevelDB with Node throws error on creation


I am just trying to open a db through:

let LevelUP   = require('levelup');
let LevelDown = require('leveldown');
let path = require('os').homedir() + '/keys.db';
let db  = LevelUP(LevelDown(path));

... and getting an error. The Error object traces as...

message: "IO error: /Users/myname/db/base.db/LOCK: No such file or directory"

OS: MacOS Sierra


Solution

  • As per discussion at GitHub, leveldown library doesn't recursively create the folders down the DB file, so you need to create them by your self before running the code. Also, make sure the user which is running the script has the permissions to do so.