I'm building portable node js server using electron. I'm using SQLITE database for storing data.
In development mode I put database file test.db
in directory where is my Main.js
file and everything is running perfectly.
When I deploy my app electron-builder --mac
and run it, it cannot access to database file. (File not found)
So my question is where should I store my test.db
file so it's working both in development and production mode?
Is it possible to embed db file somewhere while creating application for win/mac/linux so end user doesn't need to take care where is db file located?
Thank you
I'm building portable node js server using electron. I'm using SQLITE database for storing data.
In development mode I put database file test.db
in directory where is my Main.js
file and everything is running perfectly.
When I deploy my app electron-builder --mac
and run it, it cannot access to database file. (File not found)
So my question is where should I store my test.db
file so it's working both in development and production mode?
Is it possible to embed db file somewhere while creating application for win/mac/linux so end user doesn't need to take care where is db file located?
Thank you
Share Improve this question asked Feb 19, 2021 at 20:35 HardRockHardRock 1,0912 gold badges17 silver badges43 bronze badges1 Answer
Reset to default 5you can store it into application data,
const dbPath = path.join(app.getPath("userData"), "sample.db")
Check out docs here, https://www.electronjs/docs/api/app#appgetpathname
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744896778a4599741.html
评论列表(0条)