Npm i fails

When running npm i in the root dir of the project, I get the following error:

> @joplin/app-desktop@1.4.7 build /Users/tessus/data/work/joplin/packages/app-desktop
> gulp build

[13:03:34] Using gulpfile ~/data/work/joplin/packages/app-desktop/gulpfile.js
[13:03:34] Starting 'build'...
[13:03:34] Starting 'compileScripts'...
[13:03:34] Starting 'compilePackageInfo'...
[13:03:34] Starting 'copyPluginAssets'...
[13:03:34] Starting 'copyTinyMceLangs'...
[13:03:34] Starting 'updateIgnoredTypeScriptBuild'...
Copying to /Users/tessus/data/work/joplin/packages/app-desktop/tools/../gui/note-viewer/pluginAssets
Copying /Users/tessus/data/work/joplin/packages/app-desktop/tools/../../../Assets/TinyMCE/langs => /Users/tessus/data/work/joplin/packages/app-desktop/tools/../node_modules/tinymce/langs
[13:03:35] Finished 'compileScripts' after 536 ms
[13:03:35] Finished 'compilePackageInfo' after 537 ms
[13:03:35] Finished 'updateIgnoredTypeScriptBuild' after 547 ms
Copying to /Users/tessus/data/work/joplin/packages/app-desktop/tools/../pluginAssets
[13:03:35] Finished 'copyTinyMceLangs' after 597 ms
[13:03:35] Finished 'copyPluginAssets' after 661 ms
[13:03:35] Finished 'build' after 663 ms
[13:03:35] Using gulpfile ~/data/work/joplin/packages/app-desktop/gulpfile.js
[13:03:35] Starting 'electronRebuild'...
Running: "/Users/tessus/data/work/joplin/packages/app-desktop/tools/../node_modules/.bin/electron-rebuild"
[13:03:37] 'electronRebuild' errored after 2.16 s
[13:03:37] Error: Command failed: "/Users/tessus/data/work/joplin/packages/app-desktop/tools/../node_modules/.bin/electron-rebuild"
- Searching dependency tree
✖ Rebuild Failed

An unhandled error occurred inside electron-rebuild
gyp: Undefined variable napi_build_version in binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/lib/nodejs/node-v10.16.3/bin/node" "/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/.bin/node-gyp" "rebuild" "--target=8.2.5" "--arch=x64" "--dist-url=https://www.electronjs.org/headers" "--build-from-source" "--module_name=node_sqlite3" "--module_path=/Users/tessus/data/work/joplin/packages/tools/node_modules/sqlite3/lib/binding/napi-v{napi_build_version}-darwin-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v5.0.0/{toolset}/" "--package_name=napi-v{napi_build_version}-darwin-x64.tar.gz"
gyp ERR! cwd /Users/tessus/data/work/joplin/packages/tools/node_modules/sqlite3
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok

Failed with exit code: 1

Error: gyp: Undefined variable napi_build_version in binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/lib/nodejs/node-v10.16.3/bin/node" "/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/.bin/node-gyp" "rebuild" "--target=8.2.5" "--arch=x64" "--dist-url=https://www.electronjs.org/headers" "--build-from-source" "--module_name=node_sqlite3" "--module_path=/Users/tessus/data/work/joplin/packages/tools/node_modules/sqlite3/lib/binding/napi-v{napi_build_version}-darwin-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v5.0.0/{toolset}/" "--package_name=napi-v{napi_build_version}-darwin-x64.tar.gz"
gyp ERR! cwd /Users/tessus/data/work/joplin/packages/tools/node_modules/sqlite3
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok

Failed with exit code: 1
    at SafeSubscriber._error (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/spawn-rx/lib/src/index.js:267:84)
    at SafeSubscriber.__tryOrUnsub (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/rxjs/internal/Subscriber.js:205:16)
    at SafeSubscriber.error (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/rxjs/internal/Subscriber.js:156:26)
    at Subscriber._error (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/rxjs/internal/Subscriber.js:92:26)
    at Subscriber.error (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/rxjs/internal/Subscriber.js:72:18)
    at MapSubscriber.Subscriber._error (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/rxjs/internal/Subscriber.js:92:26)
    at MapSubscriber.Subscriber.error (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/rxjs/internal/Subscriber.js:72:18)
    at SafeSubscriber._next (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/spawn-rx/lib/src/index.js:242:65)
    at SafeSubscriber.__tryOrUnsub (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/rxjs/internal/Subscriber.js:205:16)
    at SafeSubscriber.next (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/rxjs/internal/Subscriber.js:143:22)

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:198:13)
    at ChildProcess.EventEmitter.emit (domain.js:466:23)
    at maybeClose (internal/child_process.js:982:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:198:13)
    at Socket.EventEmitter.emit (domain.js:466:23)
    at Pipe._handle.close (net.js:606:12)
lerna info lifecycle @joplin/app-desktop@1.4.7~postinstall: Failed to exec postinstall script

> @joplin/app-mobile@0.8.9 postinstall /Users/tessus/data/work/joplin/packages/app-mobile
> jetify && npm run build

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! root@ postinstall: `lerna bootstrap --no-ci && npm run tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the root@ postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tessus/.npm/_logs/2020-11-10T18_03_37_907Z-debug.log

Not sure why, because this worked yesterday...

I'm on dev 06f2fda94

Has anyone seen this error before?

Maybe 'npm run clean' first?

Nope, unfortunately that did nothing.

How about this? https://github.com/mapbox/node-sqlite3/issues/1359#issuecomment-718797922

Nope, I ran npm i node-gyp@latest in the root dir and packages/app-desktop.

I'm still getting the same error.

It seems that npm i in the root dir installs node-gyp 6.1.0 and thus replaces the latest one.

Whatever I try to do, the npm i does not use my globally installed node-gyp, which is the latest version (7.1.2)

It is still using 6.1.0
An unhandled error occurred inside electron-rebuild
gyp: Undefined variable napi_build_version in binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/lib/nodejs/node-v10.16.3/bin/node" "/Users/tessus/data/work/joplin/packages/app-desktop/node_modules/.bin/node-gyp" "rebuild" "--target=8.2.5" "--arch=x64" "--dist-url=https://www.electronjs.org/headers" "--build-from-source" "--module_name=node_sqlite3" "--module_path=/Users/tessus/data/work/joplin/packages/tools/node_modules/sqlite3/lib/binding/napi-v{napi_build_version}-darwin-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v5.0.0/{toolset}/" "--package_name=napi-v{napi_build_version}-darwin-x64.tar.gz"
gyp ERR! cwd /Users/tessus/data/work/joplin/packages/tools/node_modules/sqlite3
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok

I haven't done anything special with node-gyp in a while, I think in my case it's just using whatever node-gyp version is declared in the dependencies. Perhaps you should actually uninstall the global one and see what happens.

I actually installed the global one 2 hours ago. I tried the step from another comment in the issue you posted:

npm i -g node-gyp@latest && npm config set node_gyp "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js"

But that didn't work either.

@laurent which node version do you use? Maybe mine is too old. Are you able to run npm i on macOS without errors?

Another thing I noticed is that npm i won't work in the packages/app-desktop dir. It will only work in the root dir, which is a shame since it always does ALL packages (and thus takes rather long).

Node 12 on WSL and Node 14 on Windows. Haven't tried on macOS lately.

I think it's not too bad actually. The only thing that takes long is the electronRebuild command, which you'd need to run anyway for the desktop app. Maybe we should exclude the clipper from the global npm i because it's a bit slow too and not so necessary.

Also I expect you can install the desktop app only using npx lerna bootstrap --scope @joplin/app-desktop from the root, although I haven't tried that.

Ok, I will try node 14 on macOS. Maybe that fixes it... Fingers crossed.

With node 14.15.0 it works!

1 Like