Cannot find module: node_sqlite3.node

Hi, I tried to install Joplin terminal app on Mac OSX. After I installed it via brew, I got the following error when I ran the app.

Error: Cannot find module ‘/usr/local/Cellar/joplin/1.0.107/libexec/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v57-darwin-x64/node_sqlite3.node’

I checked the directory and found that my sqlite3 binding is node-v64-darwin-x64. How can I fix this error? Thanks!

i would suggest to install the missing node module but it looks like a bug with the macos packaging

Try running npm run pack

I figured out the issue. Looks like Joplin installed node 10 as a dependency but my current node was version 8 under nvm. Is it possible to specify the path to node in Joplin?

There are several issues about this on the forum but I forgot how it was solve. Maybe search for “nvm” to see how other people figured it out.

Just FYI, Still relevant in 2020 on Catalina. I wonder whether this has anything to do with the cask app which I’d installed before installing terminal.

Just encountered the same issue trying to run the Joplin Terminal app on macOS 10.15.4 (installed with brew install joplin):

% joplin 
internal/modules/cjs/loader.js:979
  throw err;
  ^

Error: Cannot find module '/usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v79-darwin-x64/node_sqlite3.node'
Require stack:
- /usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3-binding.js
- /usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3.js
- /usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/lib/database-driver-node.js
- /usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/lib/BaseApplication.js
- /usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/app.js
- /usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/main.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)
    at Function.Module._load (internal/modules/cjs/loader.js:859:27)
    at Module.require (internal/modules/cjs/loader.js:1036:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3-binding.js:4:15)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Module.require (internal/modules/cjs/loader.js:1036:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3-binding.js',
    '/usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3.js',
    '/usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/lib/database-driver-node.js',
    '/usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/lib/BaseApplication.js',
    '/usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/app.js',
    '/usr/local/Cellar/joplin/1.0.164/libexec/lib/node_modules/joplin/main.js'
  ]
}

Please contact brew. We only support npm to install the cli version.

But I think there have been a lot of topics in this forum about this and there should be a solution somewhere.

I followed the instructions on https://joplinapp.org which tell me to use brew.

brew install joplin

Is there another way to install it?

Oops, I really think we have to change that documentation (the only supported way is the instruction for Linux/Windows).

npm install -g joplin

You might have to get around permission problems by setting the NPM_CONFIG_PREFIX=~/.joplin-bin

P.S.: I’ll change the documentation in the next few days

Awesome, that worked straight away! (I don't think I needed to set the prefix.)

Thanks :slight_smile:

Glad it worked!

Btw, I’ve changed the documentation already. We often run into issues with other packages or portage systems and we can’t support them all.

Good job! Also needs updating here:

https://joplinapp.org/terminal/

Yes, you are right. Will do in a bit.

I think:

NPM_CONFIG_PREFIX=~/.joplin-bin

and

npm install -g joplin

…should be on separate lines? (Or with a semicolon in between at least)

https://joplinapp.org
https://joplinapp.org/terminal/

Nope. The commands must be on the same line or if you want to use separate lines, you will have to use export NPM_CONFIG_PREFIX.... instead.

Well I've learned something new there! Thanks @tessus :slight_smile: