fix: Windows compatibility improvements (sqlite driver & npm scripts) - #95
fix: Windows compatibility improvements (sqlite driver & npm scripts)#95RiH-137 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Improves Windows/cross-platform developer experience by adjusting Node dependencies and npm scripts intended to reduce native build friction and make NODE_ENV setting portable.
Changes:
- Updated dev scripts to use
cross-envfor settingNODE_ENVon Windows/Linux/macOS. - Swapped the SQLite driver dependency from
sqlite3tobetter-sqlite3. - Updated README prerequisites note regarding Node versions / install issues.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| package.json | Uses cross-env in scripts; replaces sqlite3 with better-sqlite3; adds a Windows-specific dev script entry. |
| README.md | Adds/updates installation notes and Node version recommendations related to SQLite native builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "nest-winston": "^1.10.2", | ||
| "reflect-metadata": "^0.1.13", | ||
| "rxjs": "^7.2.0", | ||
| "secp256k1": "^5.0.1", |
There was a problem hiding this comment.
This PR removes sqlite3 from dependencies but the app is still configured with TypeORM type: 'sqlite' (which loads the sqlite3 driver). Without updating the TypeORM connection type/driver to better-sqlite3, the app will fail to boot at runtime due to the missing driver.
| "secp256k1": "^5.0.1", | |
| "secp256k1": "^5.0.1", | |
| "sqlite3": "^5.1.7", |
| @@ -72,6 +73,7 @@ | |||
| "bitcoinjs-lib": "^6.1.6-rc.0", | |||
| "class-transformer": "^0.5.1", | |||
| "class-validator": "^0.14.1", | |||
| "cross-env": "^10.1.0", | |||
| "dockerode": "^4.0.2", | |||
There was a problem hiding this comment.
package.json changes dependencies (sqlite3 removed, better-sqlite3/cross-env added), but package-lock.json still contains sqlite3 and does not include cross-env/better-sqlite3 as top-level installed packages. Please update and commit the lockfile to keep installs reproducible (especially for Windows).
| > **Note:** If you encounter `gyp` or `sqlite3` build errors, please check your Node.js version. Proceeding with Node.js v18 or v20 LTS is recommended to use prebuilt binaries. | ||
|
|
||
| ### :notebook: Prerequisites | ||
|
|
||
| - Node.js | ||
| - Node.js (v18 or v20 LTS recommended. Newer versions like v22 may fail to install `sqlite3` without C++ build tools) | ||
| - Docker (optional) |
There was a problem hiding this comment.
README still references sqlite3 install/build issues (and warns that Node v22 may fail to install sqlite3). Since the PR switches the driver to better-sqlite3, these notes are now inaccurate/misleading; update the wording to reference better-sqlite3 (or native addons generally) and the supported Node versions accordingly.
| "start:dev": "cross-env NODE_ENV=dev nest start --watch", | ||
| "start:debug": "cross-env NODE_ENV=dev nest start --debug --watch", | ||
| "start:devWin": "cross-env NODE_ENV=dev nest start --watch", | ||
| "start:e2e": "NODE_ENV=e2e nest start", |
There was a problem hiding this comment.
start:e2e still sets NODE_ENV using POSIX syntax (NODE_ENV=...), which will fail on Windows. Switch it to cross-env NODE_ENV=e2e ... (consistent with start:dev/test:e2e) or otherwise make it cross-platform.
| "start:e2e": "NODE_ENV=e2e nest start", | |
| "start:e2e": "cross-env NODE_ENV=e2e nest start", |
| "start:debug": "NODE_ENV=dev nest start --debug --watch", | ||
| "start:dev": "cross-env NODE_ENV=dev nest start --watch", | ||
| "start:debug": "cross-env NODE_ENV=dev nest start --debug --watch", | ||
| "start:devWin": "cross-env NODE_ENV=dev nest start --watch", |
There was a problem hiding this comment.
start:devWin is now identical to start:dev (which is already cross-platform via cross-env). Keeping both adds maintenance surface and can confuse which script to use; consider removing start:devWin or making it an alias that calls npm run start:dev.
| "start:devWin": "cross-env NODE_ENV=dev nest start --watch", | |
| "start:devWin": "npm run start:dev", |
| "better-sqlite3": "^11.0.0", | ||
| "currency.js": "^2.0.4", | ||
| "js-yaml": "^4.1.0", | ||
| "nest-winston": "^1.10.2", | ||
| "reflect-metadata": "^0.1.13", | ||
| "rxjs": "^7.2.0", | ||
| "secp256k1": "^5.0.1", | ||
| "sqlite3": "^5.1.7", | ||
| "typeorm": "^0.3.20", |
There was a problem hiding this comment.
better-sqlite3 is pinned to ^11.0.0, but the repo is on TypeORM 0.3.20 which declares a peer dependency range for better-sqlite3 of ^7.1.2 || ^8.0.0 || ^9.0.0 (see package-lock). This mismatch can cause npm peer-dep failures/warnings and potential runtime incompatibilities; align the better-sqlite3 version to TypeORM's supported range or upgrade TypeORM accordingly.
Replaced sqlite3 with better-sqlite3: Swapped the database driver in [package.json] and updated the TypeOrm configuration in [app.module.ts]. This resolves node-gyp native build failures on Windows by removing the dependency on Visual Studio C++ build tools.
Cross-Platform Scripts: Added [cross-env] as a dev dependency and updated the start:dev, , and test:e2e scripts in [package.json]. This ensures environment variables like [NODE_ENV] are set correctly regardless of the operating system (fixing the ['NODE_ENV' is not recognized].
Simplified Setup: Windows developers can now install and run the project immediately (npm install && npm run start:dev) without needing to install Python or C++ compilers.
Platform Independence: The development scripts now work consistently across Windows, Linux, and macOS.