JoplinTerminal app - nodejs versions

Documenting this in case it is of interest.

$ joplin version
joplin 1.3.3 (prod)

$ npm --version
6.14.8

Joplin Terminal version failed when the system (linux Solus) updated nodejs

node --version v12.19.0

to

node --version v14.14.0

When I rolled back to the v12.19.0 version, all worked well again.

Here is the output to the terminal with v14.14.0 when joplin is started:

john@jon ~ $ joplin
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module '/home/john/.joplin-bin/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v83-linux-x64/node_sqlite3.node'
Require stack:
- /home/john/.joplin-bin/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3-binding.js
- /home/john/.joplin-bin/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3.js
- /home/john/.joplin-bin/lib/node_modules/joplin/lib/database-driver-node.js
- /home/john/.joplin-bin/lib/node_modules/joplin/lib/BaseApplication.js
- /home/john/.joplin-bin/lib/node_modules/joplin/app.js
- /home/john/.joplin-bin/lib/node_modules/joplin/main.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/john/.joplin-bin/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3-binding.js:4:15)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/john/.joplin-bin/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3-binding.js',
    '/home/john/.joplin-bin/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3.js',
    '/home/john/.joplin-bin/lib/node_modules/joplin/lib/database-driver-node.js',
    '/home/john/.joplin-bin/lib/node_modules/joplin/lib/BaseApplication.js',
    '/home/john/.joplin-bin/lib/node_modules/joplin/app.js',
    '/home/john/.joplin-bin/lib/node_modules/joplin/main.js'
  ]
}

I'm getting an almost identical issue when trying to use the cli in any way, except joplin seems to be looking for the 'node-v88-linux-x64' directory, when that path holds node-v83-linux-x64 for me.

I'm on arch linux, and node recently updated: upgraded nodejs (14.14.0-1 -> 15.0.1-1)

My output if it's any help:

node:internal/modules/cjs/loader:903
  throw err;
  ^

Error: Cannot find module '/usr/share/joplin-cli/node_modules/sqlite3/lib/binding/node-v88-linux-x64/node_sqlite3.node'
Require stack:
- /usr/share/joplin-cli/node_modules/sqlite3/lib/sqlite3.js
- /usr/share/joplin-cli/lib/database-driver-node.js
- /usr/share/joplin-cli/lib/BaseApplication.js
- /usr/share/joplin-cli/app.js
- /usr/share/joplin-cli/main.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:900:15)
    at Function.Module._load (node:internal/modules/cjs/loader:745:27)
    at Module.require (node:internal/modules/cjs/loader:972:19)
    at require (node:internal/modules/cjs/helpers:88:18)
    at Object.<anonymous> (/usr/share/joplin-cli/node_modules/sqlite3/lib/sqlite3.js:4:15)
    at Module._compile (node:internal/modules/cjs/loader:1083:30)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:10)
    at Module.load (node:internal/modules/cjs/loader:948:32)
    at Function.Module._load (node:internal/modules/cjs/loader:789:14)
    at Module.require (node:internal/modules/cjs/loader:972:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/share/joplin-cli/node_modules/sqlite3/lib/sqlite3.js',
    '/usr/share/joplin-cli/lib/database-driver-node.js',
    '/usr/share/joplin-cli/lib/BaseApplication.js',
    '/usr/share/joplin-cli/app.js',
    '/usr/share/joplin-cli/main.js'
  ]
}

Thanks for sharing, @mascot. It does look like the same issue. I don't know if it's Joplin or nodejs? Up to now it's been solid through all updates.

I use the terminal version for automated backups of the notes, and don't usually view or edit notes with it. I'll just stay with the previous version of nodejs for now, and whenever either Joplin or `nodejs' update try again.

I use the terminal version for automated backups of the notes, and don't usually view or edit notes with it.

Same here.

I've managed to get it working by following laurent22's advice here, then reinstalling joplin: Cannot find module sqlite3 · Issue #29 · laurent22/joplin · GitHub

1 Like

The sqlite nodejs package has been a pain in our asses since the beginning. During install it builds a binding lib that apparently only works with the nodejs version it was compiled for.

Maybe you should open an issue with sqlite and ask them to be more flexible.

Thanks, @mascot. Setting up the environment according to your link has solved the problem.

1 Like

Thanks for the input, @tessus. I dimly remember a similar issue I had a long time back, and that was down to how I had the nodejs environment set up also.

In case it's useful to anyone else, here follows how I set it up. Maybe not the correct way, but it worked for me. Disclaimer: I have no knowledge of nodejs :slight_smile:

This for linux, but similar steps for MAC or Windows

(This puts joplin under the ~/npm-global/ tree, rather than ~/.joplin-bin, but as the database is stored with config files in a different location, it makes no difference)

Assuming nodejs is installed:

  1. npm install -g npm (with admin privileges)
  2. mkdir ~/.npm-global
  3. Append $HOME/.npm-global/bin to your PATH statement (.bashrc, in linux and then source .bashrc)
  4. Set npm config prefix: npm config set prefix $HOME/.npm-global, this will create ~/.npmrc if it doesn't already exist)
  5. Check npm config prefix: npm config get prefix to confirm
  6. npm install -g joplin
  7. If it doesn't succeed, check for missing libraries in the error output, install them and try again

I'll continue with npm install -g joplin for updates and see if it stands the test of time.