Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Update Node.js version#228

Merged
eliandoran merged 14 commits intodevelopfrom
feature/update_to_node20
Jul 20, 2024
Merged

Update Node.js version#228
eliandoran merged 14 commits intodevelopfrom
feature/update_to_node20

Conversation

@eliandoran
Copy link
Copy Markdown
Contributor

@eliandoran eliandoran commented Jul 16, 2024

Closes TriliumNext/Trilium#5074 .

  1. The change to Node 20 does not seem to cause any issues with the code base, being an LTS update.
  2. Updated better-sqlite3 from 8.4.0 to 8.5.0 because it contains prebuilt binaries for Electron v25. This should make npm run switch-electron run faster and not require additional tools on some operating systems.

@eliandoran eliandoran force-pushed the feature/update_to_node20 branch from e3be8ac to 6a2ed4f Compare July 16, 2024 21:59
@eliandoran eliandoran marked this pull request as ready for review July 16, 2024 22:04
@eliandoran eliandoran requested a review from a team July 16, 2024 22:04
@eliandoran
Copy link
Copy Markdown
Contributor Author

eliandoran commented Jul 16, 2024

@TriliumNext/development , I would appreciate a local test of this PR.
You need to make sure node --version points to a Node 20 version, not 18.
Test npm run start-server, but also npm run switch-electron followed by npm run start-electron (don't forget to switch back to server with npm run switch-server).

Artifacts built by the CI are available here: https://github.com/TriliumNext/Notes/actions/runs/9964686407

@eliandoran eliandoran added this to the v0.90.1-beta milestone Jul 17, 2024
@alexpietsch
Copy link
Copy Markdown

@eliandoran I tested it on my Windows PC: I made a fresh clone of the repo, ran npm i, and then npm run start-server.
I chose "I am a new user" and could set up. After logging in, I see a lot of Error: Cannot set headers after they are sent to the client errors. The reason is Error: EPERM: operation not permitted, rename 'B:\Notes\data\sessions\brERX1URXz1lNi77UEO9Nnq1rj79Dt3H.json.4212621842' -> 'B:\Notes\data\sessions\brERX1URXz1lNi77UEO9Nnq1rj79Dt3H.json']

I did the same for electron, and after running npm run start-electron I only get an error

Error: The module '\\?\B:\Notes\node_modules\better-sqlite3\build\Release\better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 115. This version of Node.js requires
NODE_MODULE_VERSION 116. Please try re-compiling or re-installing

But I was able to start electron and use it perfectly fine by first starting the server, completing the setup, stopping the server, then running npm run switch-electron followed by npm run start-electron.
I also tried to clone the repo, installing dependencies, running npm run switch-electron followed by npm run start-electron, but had no success.

@eliandoran
Copy link
Copy Markdown
Contributor Author

@alexpietsch , can you confirm your Node version using node --version?

And also, what is the output of npm run switch-electron?

@eliandoran
Copy link
Copy Markdown
Contributor Author

@alexpietsch ,

For the Electron build, try this in a Git Bash:

git fetch
git checkout origin/feature/update_to_node20
rm -r data node_modules
npm i
npm run switch-electron
npm run start-electron

For me it started just fine.

@alexpietsch
Copy link
Copy Markdown

@alexpietsch , can you confirm your Node version using node --version?

Output: v20.15.1

And also, what is the output of npm run switch-electron?

This script does not work on windows (because rm is not recognized). I did the steps manually (deleting ./node_modules/better-sqlite3, then running npm install)

I followed your steps (with GitBash) and it worked!
But we should take a look if we want to support windows.

@eliandoran
Copy link
Copy Markdown
Contributor Author

@alexpietsch , I've just pushed a change regarding rm -rf, using rimraf should make it cross-platform.
Let me know if you have any other issues.

Regarding

[Error: EPERM: operation not permitted, rename 'C:\Users\Elian\Projects\TriliumNext\data\sessions\WMCk1bAlG6HCBjNajFh-NPcVNZlF1dKn.json.1509196086' -> 'C:\Users\Elian\Projects\TriliumNext\data\sessions\WMCk1bAlG6HCBjNajFh-NPcVNZlF1dKn.json'] {
  errno: -4048,
  code: 'EPERM',
  syscall: 'rename',
  path: 'C:\\Users\\Elian\\Projects\\TriliumNext\\data\\sessions\\WMCk1bAlG6HCBjNajFh-NPcVNZlF1dKn.json.1509196086',
  dest: 'C:\\Users\\Elian\\Projects\\TriliumNext\\data\\sessions\\WMCk1bAlG6HCBjNajFh-NPcVNZlF1dKn.json'
}

That one is caused by an upstream dependency, I'll create a separate ticket for it.

Let me know if the PR is OK so I can merge it for the upcoming release (soon!).

@eliandoran eliandoran merged commit 645c16e into develop Jul 20, 2024
@eliandoran eliandoran deleted the feature/update_to_node20 branch July 20, 2024 16:06
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Node.js version Update tooling dependencies

2 participants