Joplin will not start on linux after building from source

I have tried to makepkg from the git ressource yesterday, and when I start joplin I get this error

┌[~/joplin]
└─> joplin
internal/modules/cjs/loader.js:969
throw err;
^

Error: Cannot find module ‘lib/JoplinServerApi.js’
Require stack:

  • /usr/share/joplin-cli/lib/SyncTargetNextcloud.js
  • /usr/share/joplin-cli/lib/BaseApplication.js
  • /usr/share/joplin-cli/app.js
  • /usr/share/joplin-cli/main.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:17)
    at Function.Module._load (internal/modules/cjs/loader.js:859:27)
    at Module.require (internal/modules/cjs/loader.js:1028:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object. (/usr/share/joplin-cli/lib/SyncTargetNextcloud.js:9:25)
    at Module._compile (internal/modules/cjs/loader.js:1139:30)
    at Object.Module._extensions…js (internal/modules/cjs/loader.js:1159:10)
    at Module.load (internal/modules/cjs/loader.js:988:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Module.require (internal/modules/cjs/loader.js:1028:19) {
    code: ‘MODULE_NOT_FOUND’,
    requireStack: [
    ‘/usr/share/joplin-cli/lib/SyncTargetNextcloud.js’,
    ‘/usr/share/joplin-cli/lib/BaseApplication.js’,
    ‘/usr/share/joplin-cli/app.js’,
    ‘/usr/share/joplin-cli/main.js’
    ]
    }

Any help greatly appreciated since I already use it on another computer and need it on this one!
Thanks!

The new typescript code broke some of the isolation between the different pieces. You need to run npm run tsc at the root level before running the build script in the cli folder or the desktop folder.

Thanks for coming back to me. I’m really a noob when it comes to computers, but if I run

sudo npm run tsc

in the joplin git folder, I get this error

┌[~/joplin]
└─> sudo npm run tsc
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/bruce/joplin/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open ‘/home/bruce/joplin/package.json’
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-01-05T19_03_45_804Z-debug.log

No problem. Always happy to help. For me, the following works to build joplin-cli from source. (just tried it in a new directory) You also probably don’t need sudo just fyi.

git clone https://github.com/laurent22/joplin.git
cd joplin
# Run your installs
npm i && cd Tools && npm i && cd .. && \
    cd CliClient && npm i && cd ..
# copylib because we've created an implicit dependency between the desktop app and the cli app
npm run copyLib && npm run tsc && cd CliClient && ./build.sh 

To run the build you’ve just done go to the CliClient directory and run this:

./run.sh

P.S.: This isn’t the cleanest shell script in the world as I scavenged it from my WIP Dockerfile.

Btw, makepkg suggests to me that you’re attempting to install from AUR. Last time I checked, the PKGBUILD was broken there for 1.0.777, but things may have changed in the last week or so.

If you’re curious, this is the repo that I’m 99.99% sure houses those files (my AUR knowledge is increasing, but definitely not good yet):

I use this update script in the git root:

git co -- ElectronClient/app/package-lock.json

git co master
git pull
npm install
( cd Tools && npm install )
npm run copyLib
npm run tsc
cd ElectronClient/app
npm install

Then I run directly from git:

cd ElectronClient/app
gitrev=`git rev-parse --short HEAD`
./node_modules/.bin/electron . --env git-$gitrev
1 Like

That’s pretty cool. I think it would really be ideal if we had (isolated) npm scripts (ie. npm run build, npm start, etc) that took care of all of this madness in each of the client folders. That way it’s as easy as git pull, probably npm install, and then running the required build scripts. Though that’s partially because I would like the PKGBUILD to stop breaking all the time… .

Btw, it is in fact broken again. I’ll see if I can fix it and open a PR to that repo.

Thanks again for your time, truly appreciated!

Yes I am trying to install from the AUR but as you pointed out, something is broken there. I was able to install it manually by following the comment section, but once I start the app I get the error above.

Following your script does make it work, thanks! I’m still going to have to wait I guess because doing it this way I won’t have updates through the package manager right?

I think it would depend on how you went about doing the install, but honestly I’m not sure. I run updates at semi-regular intervals so while my Manjaro install does have a package management GUI that tells me when things are out of date, I almost always ignore it.

What I’ve been doing for the past few weeks as I was playing with some unreleased stuff was I built the app locally and symlinked those files into my PATH so they would appear globally (ln -s ~/Projects/joplin/joplin/CliClient/build/main.js ~/.local/bin/joplin if you’re curious). That’s enough to solve my problem, but you may need more.

Also, here’s the PR with the fix to the PKGBUILD.

Wow thank you so much for taking the time to open this and report back! I’ve learned quite a lot today thanks to you!

1 Like

npm i should install everything, but the TypeScript setup and copyLib stuff is quite new so probably something is missing.