So, I have run into an issue that I am unable to solve... I have an nbb app that I am working on, and it's now at the point that I want to package it... The app requires the presence of an sqlite3 database, and having set up an index.mjs and made the relevant additions to the package.json I have arrived at a point where the app runs successfully with its configured "binary" name if I run it in the actual directory where the code is, or if I run it by navigating to the location of the link that's created by running npm install -g (in my case /usr/lib/node_modules/birthdayman-sqlite), however running it anywhere else gets me this huge error ( https://pastebin.com/hKx6Nk9a ), which seems to be the app complaining that the DB is not present. The thing is that it is present. The Github repo is https://github.com/maleghast/birthdayman-sqlite - any help gratefully received; I don't want to push it to https://www.npmjs.com until I know it's going to work (clearly), Thanks in advance
(Oh, I know that the repo does not have a file named birthdays.db I will rename the file birthdays.db.template as the blank db when I am done testing - I have a birthdays.db in my path / version on my machine)
(and yes the README.md is out of date now too, but I will update it properly once I have fixed all this stuff 😉 )
@maleghast https://github.com/mifi/stacktracify or https://github.com/xfthhxk/unminify may help you investigate the stack trace and give you hints at the problem. I haven't had need to use these so no further advice off the top of my head.
@maleghast I think here:
(def db (sql. (str (path/resolve) "/birthdays.db")))
the db always is picked from the current working directory
So if you don't want that, you should change something about that
A few ideas:
• Always pick ~/.birthdayman/birthdays.db or so
• Support an env var so people can tweak the location
• Always locate the db close to the script, e.g. using *file*
@borkdude - Thanks, I've fixed it using *file* - just one question, how do I get clj-kondo to accept *file* as it works, clearly, but cll-kondo sees it as an unresolved symbol
(I have pushed the app to NPM, but I desperately need to update the README!)
you could maybe use nbb.core/*file* instead
Oh thanks, I will try that
Thanks, @borkdude that worked perfectly and it's live -> https://www.npmjs.com/package/birthdayman-sqlite Not really expecting anyone to use it, but I am actually using it, so I thought I may as well put it up and see if people use it 🙂
awesome!
Thanks for nbb and the help - really appreciate it 🙂