We need node v18 - the latest LTS. On linux a convenient way is to use Node Version Manager (https://github.com/nvm-sh/nvm)
nvm install lts/hydrogen
nvm use lts/hydrogen
Next, in your shell, change directory to the bahis-desk project and run:
npm install
npm run dev
On Windows install node direct from their website, or by clicking here.
Please tick to install all additional tools with "chocolatey" that should cover all of the other requirements (visual studio, python etc.)
Just run npm run format
Just run npm run lint-electron
for the electron code and npm run lint-react
for the react code.
Scroll up - do you see "fatal error: all goroutines are asleep - deadlock!". If so, I think you are using the wrong version of node. Try running:
node --version
And then select the correct version with nvm
or whatever you're using.
If you get an error like this (note: version numbers may vary):
Uncaught Error: The module './node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 69. Please try re-compiling or re-installing
First, check you are using the correct version of node:
node --version
Then, if you are, run:
npm run fix-better-sqlite-build-error
In order to reset the database before the next build you need to remove the bahis files, e.g. on linux:
rm -rf ~/.config/bahis
The exact location of your database will be in the electron-debug.log file and / or printed to your console.
There is some leak in UI code that might give an error saying that there are too many watchers. Try this
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
npm run build
We have three .env
files:
.env
- for local development.env.staging
- for staging builds.env.production
- for production buildsNote that all variables in .env
files should follow the naming format of: VITE_[SCOPE]_[REALLY_USEFUL_NAME]
, where SCOPE
is on of [BAHIS
, ELECTRON
, REACT
] depending on whether it defines how the system interacts with the BAHIS server, the electron main process, or the react renderer process.
Once variables are read into the code they can loose the VITE_
prefix, e.g. VITE_BAHIS_SERVER_URL
becomes BAHIS_SERVER_URL
.
If you have a .env.local
file, this will be used instead of .env
for local development, e.g. your .env.local
if you are testing local server changes might look like this:
VITE_BAHIS_SERVER_URL=http://localhost
Note that adding environment variables is a multistep process and depends on what you're trying to acheive.
If you're trying to set an environment variable that depends only on the build mode (development
/ staging
/ production
), e.g. BAHIS_SERVER_URL
might be http://localhost
in development
and http://www.bahis2-dev.net
in staging
and if you are accessing this variable in the electron main process (probably the most common scenario), you can hard code this into the switch statement near the top of /electron/main.ts
. For example:
// default environment variables, i.e. for local development
let BAHIS_SERVER_URL = 'http://www.bahis2-dev.net';
// set environment variables based on mode
switch (import.meta.env.MODE) {
case 'development':
break;
case 'staging':
BAHIS_SERVER_URL = 'http://www.bahis2-dev.net';
break;
default:
break;
}
If you also want to enable the ability to override this variable from a .env
file or local shell environment, you can add the following code below the switch statement:
// overwrite anything defined in a .env file
if (import.meta.env.VITE_BAHIS_BAHIS_SERVER_URL) {
BAHIS_SERVER_URL = import.meta.env.VITE_BAHIS_BAHIS_SERVER_URL;
log.warn(`Overwriting BAHIS_SERVER_URL base on environment variables or .env[.local] file.`)
}
Store these inside an appropriate .env
file:
.env
(and if it changes then .env.staging
and / or .env.production
)..env.local
and document it in the README.md
file.