Build joplin from source

Trying to build Jopin in macOS m1, on dev branch

followed joplin/BUILD.md at dev · laurent22/joplin · GitHub

❯ npm install

> postinstall
> npm run bootstrap --no-ci && npm run build


> bootstrap
> lerna bootstrap --force-local --no-ci

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

Error: Cannot find module '@lerna/cli'
Require stack:
- /Users/felix/github/joplin/node_modules/lerna/index.js
- /Users/felix/github/joplin/node_modules/lerna/cli.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
    at Function.Module._load (node:internal/modules/cjs/loader:763:27)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/Users/felix/github/joplin/node_modules/lerna/index.js:3:13)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Module.require (node:internal/modules/cjs/loader:991:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/felix/github/joplin/node_modules/lerna/index.js',
    '/Users/felix/github/joplin/node_modules/lerna/cli.js'
  ]
}
npm ERR! code 1
npm ERR! path /Users/felix/github/joplin
npm ERR! command failed
npm ERR! command sh -c lerna bootstrap --force-local --no-ci

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/felix/.npm/_logs/2021-07-22T09_24_50_9

I have tried npm install -g lerna, then run npm install again still get this error, wondering if anyone encountered this too?

Lerna is installed with the dependencies so you shouldn't have to install it globally. In fact, maybe try to uninstall it globally to see if it helps?

Also what is the error message if you manually run npx lerna bootstrap --force-local --no-ci?

Got here

❯ npx lerna bootstrap --force-local --no-ci
lerna notice cli v4.0.0
lerna info versioning independent
lerna info Bootstrapping 15 packages
lerna info Installing external dependencies
lerna info Symlinking packages and binaries
lerna info lifecycle @joplin/app-clipper@1.0.8~postinstall: @joplin/app-clipper@1.0.8
lerna info lifecycle @joplin/app-desktop@2.2.0~postinstall: @joplin/app-desktop@2.2.0
lerna info lifecycle @joplin/app-mobile@0.8.9~postinstall: @joplin/app-mobile@0.8.9

> @joplin/app-clipper@1.0.8 postinstall /Users/felix/github/joplin/packages/app-clipper
> cd popup && npm install

⸨                  ⸩ ⠙ reify:@babel/code-frame: timing reify:loadBundles Completed in 1007ms

> joplin-webclipper-popup@0.1.0 postinstall
> node postinstall.js && npm run build


> joplin-webclipper-popup@0.1.0 build
> node scripts/build.js SKIP_PREFLIGHT_CHECK

Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run the following command: `npm update`
Compiled successfully.

File sizes after gzip:

  47.92 KB  build/static/js/2.chunk.js
  8.53 KB   build/static/js/main.chunk.js
  775 B     build/static/js/runtime-main.js
  771 B     build/static/css/main.chunk.css

The project was built assuming it is hosted at ./.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.

Find out more about deployment here:

  bit.ly/CRA-deploy


added 1911 packages, and audited 2044 packages in 28s

29 vulnerabilities (5 low, 13 moderate, 11 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
lerna info lifecycle @joplin/app-clipper@1.0.8~postinstall: Failed to exec postinstall script

> @joplin/app-desktop@2.2.0 postinstall /Users/felix/github/joplin/packages/app-desktop
> npm run build

npm ERR! code 1
npm ERR! path /Users/felix/github/joplin
npm ERR! command failed
npm ERR! command sh -c lerna bootstrap --force-local --no-ci

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/felix/.npm/_logs/2021-07-22T11_42_41_450Z-debug.log
❯

╭─ ~/github/joplin dev !9 ································································································································· ▼  2.6.5 19:42:41 ─╮
╰─❯                                                                                                                                                                            ─╯
> @joplin/app-desktop@2.2.0 build
> gulp build

Error: Cannot find module '/Users/felix/github/joplin/packages/tools/node_modules/fs-extra/lib/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:338:19)
    at Function.Module._findPath (node:internal/modules/cjs/loader:551:18)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:905:27)
    at Function.Module._load (node:internal/modules/cjs/loader:763:27)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/Users/felix/github/joplin/packages/tools/gulp/utils.js:1:12)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/felix/github/joplin/packages/tools/node_modules/fs-extra/package.json',
  requestPath: 'fs-extra'
}
npm ERR! code 1
npm ERR! path /Users/felix/github/joplin/packages/app-desktop
npm ERR! command failed
npm ERR! command sh -c gulp build

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/felix/.npm/_logs/2021-07-22T11_42_43_080Z-debug.log

None of these errors makes any sense so it's hard to tell. Also make sure you use node 12 and npm 6.

Thanks, I was using node 15.x, I thought it's fine, as the doc suggested node 10+, after switched to 12.x

> rm -rf node_modules

> npm install

sh: lerna: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! root@ bootstrap: `lerna bootstrap --force-local --no-ci`
npm ERR! spawn ENOENT


then I run npx lerna bootstrap --force-local --no-ci, it takes a looooooong time, then get error:

../src/common.cc:24:10: fatal error: 'vips/vips8' file not found
#include <vips/vips8>
         ^~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/sharp/src/common.o] Error 1

after do some search, brew install vips, after installed a lot of dependencies

then run npx lerna bootstrap --force-local --no-ci, took 1-2 hour.

got another error,

mpiling /Users/felix/github/joplin/packages/app-desktop/tools/../gui/ClipperConfigScreen.jsx...

Error: spawnSync /Users/felix/github/joplin/packages/app-desktop/tools/../node_modules/.bin/babel ENOENT
    at Object.spawnSync (internal/child_process.js:1041:20)
    at spawnSync (child_process.js:607:24)
    at /Users/felix/github/joplin/packages/app-desktop/tools/compileScripts.js:31:19
    at Array.forEach (<anonymous>)
    at convertJsx (/Users/felix/github/joplin/packages/app-desktop/tools/compileScripts.js:17:23)
    at module.exports (/Users/felix/github/joplin/packages/app-desktop/tools/compileScripts.js:45:2)
    at taskWrapper (/Users/felix/github/joplin/packages/app-desktop/node_modules/undertaker/lib/set-task.js:13:15)
    at bound (domain.js:420:14)
    at runBound (domain.js:433:12)
    at asyncRunner (/Users/felix/github/joplin/packages/app-desktop/node_modules/async-done/index.js:55:18) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawnSync /Users/felix/github/joplin/packages/app-desktop/tools/../node_modules/.bin/babel',
  path: '/Users/felix/github/joplin/packages/app-desktop/tools/../node_modules/.bin/babel',
  spawnargs: [
    '--presets',
    'react',
    '--out-file',
    '/Users/felix/github/joplin/packages/app-desktop/tools/../gui/ClipperConfigScreen.min.js',
    '/Users/felix/github/joplin/packages/app-desktop/tools/../gui/ClipperConfigScreen.jsx'
  ]
}
[22:05:07] The following tasks did not complete: build, compileScripts, compilePackageInfo, copyPluginAssets, copyTinyMceLangs, updateIgnoredTypeScriptBuild
[22:05:07] Did you forget to signal async completion?

I gave it up, maybe I'll try it on Linux sometime

Yes, not sure why even the most basic things are not working for you. Perhaps it's not compatible with macOS M1.

Did you have a fix on you issue? I am facing the same issue but no response from anyone and couldn't find this topic troubleshooting in google.

Sorry, nope, I can't build it on Arm Linux either