# Bcrypt dependency install fails on ARM64 architectures

**URL:** <https://forum.getodk.org/t/bcrypt-dependency-install-fails-on-arm64-architectures/43992>\
**Category:** Development\
**Tags:** odk-central\
**Created:** [November 26, 2023, 3:45pm UTC](https://forum.getodk.org/t/bcrypt-dependency-install-fails-on-arm64-architectures/43992 "2023-11-26T15:45:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spwoodcock](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/spwoodcock/32/33091_2.png) [@spwoodcock](https://forum.getodk.org/u/spwoodcock)\
**Post date:** [November 26, 2023, 3:45pm UTC](https://forum.getodk.org/t/bcrypt-dependency-install-fails-on-arm64-architectures/43992/1 "2023-11-26T15:45:41Z")

</div>

## Problem

For a project I work on I build Central with a slightly modified Dockerfile from the original.

The package.json is untouched & I use the same package install command:

```auto
npm clean-install --omit=dev --legacy-peer-deps --no-audit \
    --fund=false --update-notifier=false

```

This works without issues on standard AMD64 architecture.  
As part of my CI/CD workflows, I also build using ARM64 architecture under QEMU.

I get a traceback during install:

```auto
#31 297.5 npm ERR! code 1
#31 297.5 npm ERR! path /usr/odk/node_modules/bcrypt
#31 297.6 npm ERR! command failed
#31 297.6 npm ERR! command sh -c node-pre-gyp install --fallback-to-build
#31 297.6 npm ERR! Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/odk/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/usr/odk/node_modules/bcrypt/lib/binding/napi-v3 --napi_version=9 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
#31 297.6 npm ERR! node-pre-gyp info it worked if it ends with ok
#31 297.6 npm ERR! node-pre-gyp info using node-pre-gyp@1.0.9
#31 297.6 npm ERR! node-pre-gyp info using node@18.18.2 | linux | arm64
#31 297.6 npm ERR! node-pre-gyp info check checked for "/usr/odk/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" (not found)
#31 297.6 npm ERR! node-pre-gyp http GET https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-linux-arm64-glibc.tar.gz
#31 297.6 npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-linux-arm64-glibc.tar.gz 
#31 297.6 npm ERR! node-pre-gyp WARN Pre-built binaries not installable for bcrypt@5.0.1 and node@18.18.2 (node-v108 ABI, glibc) (falling back to source compile with node-gyp) 
#31 297.6 npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-linux-arm64-glibc.tar.gz 
#31 297.6 npm ERR! gyp info it worked if it ends with ok
#31 297.6 npm ERR! gyp info using node-gyp@9.4.0
#31 297.6 npm ERR! gyp info using node@18.18.2 | linux | arm64
#31 297.6 npm ERR! gyp info ok 
#31 297.6 npm ERR! gyp info it worked if it ends with ok
#31 297.6 npm ERR! gyp info using node-gyp@9.4.0
#31 297.6 npm ERR! gyp info using node@18.18.2 | linux | arm64
#31 297.6 npm ERR! gyp ERR! find Python 
#31 297.6 npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
#31 297.6 npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
#31 297.6 npm ERR! gyp ERR! find Python checking if "python3" can be used
#31 297.6 npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
#31 297.6 npm ERR! gyp ERR! find Python checking if "python" can be used
#31 297.6 npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
#31 297.6 npm ERR! gyp ERR! find Python 
#31 297.6 npm ERR! gyp ERR! find Python **********************************************************
#31 297.6 npm ERR! gyp ERR! find Python You need to install the latest version of Python.
#31 297.6 npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#31 297.6 npm ERR! gyp ERR! find Python you can try one of the following options:
#31 297.6 npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#31 297.6 npm ERR! gyp ERR! find Python (accepted by both node-gyp and npm)
#31 297.6 npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
#31 297.6 npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
#31 297.6 npm ERR! gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
#31 297.6 npm ERR! gyp ERR! find Python For more information consult the documentation at:
#31 297.6 npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#31 297.6 npm ERR! gyp ERR! find Python **********************************************************
#31 297.6 npm ERR! gyp ERR! find Python 
#31 297.6 npm ERR! gyp ERR! configure error 
#31 297.6 npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
#31 297.6 npm ERR! gyp ERR! stack at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
#31 297.6 npm ERR! gyp ERR! stack at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
#31 297.6 npm ERR! gyp ERR! stack at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16)
#31 297.6 npm ERR! gyp ERR! stack at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16)
#31 297.6 npm ERR! gyp ERR! stack at exithandler (node:child_process:430:5)
#31 297.6 npm ERR! gyp ERR! stack at ChildProcess.errorhandler (node:child_process:442:5)
#31 297.6 npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:517:28)
#31 297.6 npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:290:12)
#31 297.6 npm ERR! gyp ERR! stack at onErrorNT (node:internal/child_process:477:16)
#31 297.6 npm ERR! gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
#31 297.6 npm ERR! gyp ERR! System Linux 6.2.0-1016-azure
#31 297.6 npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/odk/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/usr/odk/node_modules/bcrypt/lib/binding/napi-v3" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
#31 297.6 npm ERR! gyp ERR! cwd /usr/odk/node_modules/bcrypt
#31 297.6 npm ERR! gyp ERR! node -v v18.18.2
#31 297.7 npm ERR! gyp ERR! node-gyp -v v9.4.0
#31 297.7 npm ERR! gyp ERR! not ok 
#31 297.7 npm ERR! node-pre-gyp ERR! build error 
#31 297.7 npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/odk/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/usr/odk/node_modules/bcrypt/lib/binding/napi-v3 --napi_version=9 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
#31 297.7 npm ERR! node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/usr/odk/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
#31 297.7 npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:517:28)
#31 297.7 npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1098:16)
#31 297.7 npm ERR! node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:303:5)
#31 297.7 npm ERR! node-pre-gyp ERR! System Linux 6.2.0-1016-azure
#31 297.7 npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/odk/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
#31 297.7 npm ERR! node-pre-gyp ERR! cwd /usr/odk/node_modules/bcrypt
#31 297.7 npm ERR! node-pre-gyp ERR! node -v v18.18.2
#31 297.7 npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.9
#31 297.7 npm ERR! node-pre-gyp ERR! not ok
#31 297.7 
#31 297.7 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-11-26T15_01_37_226Z-debug-0.log

```

The error seems to be related to node-pre-gyp during the installation of bcrypt.

## Diagnosis

After investigating it seems to be an issue in the underlying bcrypt lib not having a pre-compiled ARM64 install target.

It attempts to compile from source and fails, as Python is not installed.

This was referenced as solved, as the author released ARM64 builds:

> <https://github.com/kelektiv/node.bcrypt.js/issues/868#issuecomment-1013350220>
>
> =\> ERROR \[dependencies 3/5\] RUN npm install --production=false … 14.4s
> \------
> \> \[dependencies 3/5\] RUN npm install --production=false:
> \#12 13.35 
> \#12 13.35 \> bcrypt@5.0.1 install /usr/src/app/node\_modules/bcrypt
> \#12 13.35 \> node-pre-gyp install --fallback-to-build
> \#12 13.35 
> \#12 13.72 node-pre-gyp ERR! install response status 404 Not Found on https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt\_lib-v5.0.1-napi-v3-linux-arm64-glibc.tar.gz 
> \#12 13.72 node-pre-gyp WARN Pre-built binaries not installable for bcrypt@5.0.1 and node@14.15.5 (node-v83 ABI, glibc) (falling back to source compile with node-gyp) 
> \#12 13.72 node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt\_lib-v5.0.1-napi-v3-linux-arm64-glibc.tar.gz 
> \#12 13.86 gyp ERR! find Python 
> \#12 13.86 gyp ERR! find Python Python is not set from command line or npm configuration
> \#12 13.86 gyp ERR! find Python Python is not set from environment variable PYTHON
> \#12 13.86 gyp ERR! find Python checking if "python" can be used
> \#12 13.86 gyp ERR! find Python - "python" is not in PATH or produced an error
> \#12 13.86 gyp ERR! find Python checking if "python2" can be used
> \#12 13.86 gyp ERR! find Python - "python2" is not in PATH or produced an error
> \#12 13.86 gyp ERR! find Python checking if "python3" can be used
> \#12 13.86 gyp ERR! find Python - "python3" is not in PATH or produced an error
> \#12 13.86 gyp ERR! find Python 
> \#12 13.86 gyp ERR! find Python \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> \#12 13.86 gyp ERR! find Python You need to install the latest version of Python.
> \#12 13.86 gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
> \#12 13.86 gyp ERR! find Python you can try one of the following options:
> \#12 13.86 gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
> \#12 13.86 gyp ERR! find Python (accepted by both node-gyp and npm)
> \#12 13.86 gyp ERR! find Python - Set the environment variable PYTHON
> \#12 13.86 gyp ERR! find Python - Set the npm configuration variable python:
> \#12 13.86 gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
> \#12 13.86 gyp ERR! find Python For more information consult the documentation at:
> \#12 13.86 gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
> \#12 13.86 gyp ERR! find Python \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> \#12 13.86 gyp ERR! find Python 
> \#12 13.86 gyp ERR! configure error 
> \#12 13.86 gyp ERR! stack Error: Could not find any Python installation to use
> \#12 13.86 gyp ERR! stack at PythonFinder.fail (/usr/local/lib/node\_modules/npm/node\_modules/node-gyp/lib/find-python.js:307:47)
> \#12 13.86 gyp ERR! stack at PythonFinder.runChecks (/usr/local/lib/node\_modules/npm/node\_modules/node-gyp/lib/find-python.js:136:21)
> \#12 13.86 gyp ERR! stack at PythonFinder.\<anonymous\> (/usr/local/lib/node\_modules/npm/node\_modules/node-gyp/lib/find-python.js:179:16)
> \#12 13.86 gyp ERR! stack at PythonFinder.execFileCallback (/usr/local/lib/node\_modules/npm/node\_modules/node-gyp/lib/find-python.js:271:16)
> \#12 13.86 gyp ERR! stack at exithandler (child\_process.js:315:5)
> \#12 13.86 gyp ERR! stack at ChildProcess.errorhandler (child\_process.js:327:5)
> \#12 13.86 gyp ERR! stack at ChildProcess.emit (events.js:315:20)
> \#12 13.86 gyp ERR! stack at Process.ChildProcess.\_handle.onexit (internal/child\_process.js:275:12)
> \#12 13.86 gyp ERR! stack at onErrorNT (internal/child\_process.js:465:16)
> \#12 13.86 gyp ERR! stack at processTicksAndRejections (internal/process/task\_queues.js:80:21)
> \#12 13.86 gyp ERR! System Linux 5.10.25-linuxkit
> \#12 13.86 gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node\_modules/npm/node\_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/src/app/node\_modules/bcrypt/lib/binding/napi-v3/bcrypt\_lib.node" "--module\_name=bcrypt\_lib" "--module\_path=/usr/src/app/node\_modules/bcrypt/lib/binding/napi-v3" "--napi\_version=7" "--node\_abi\_napi=napi" "--napi\_build\_version=3" "--node\_napi\_label=napi-v3"
> \#12 13.86 gyp ERR! cwd /usr/src/app/node\_modules/bcrypt
> \#12 13.86 gyp ERR! node -v v14.15.5
> \#12 13.86 gyp ERR! node-gyp -v v5.1.0
> \#12 13.86 gyp ERR! not ok 
> \#12 13.86 node-pre-gyp ERR! build error 
> \#12 13.86 node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node\_modules/npm/node\_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/src/app/node\_modules/bcrypt/lib/binding/napi-v3/bcrypt\_lib.node --module\_name=bcrypt\_lib --module\_path=/usr/src/app/node\_modules/bcrypt/lib/binding/napi-v3 --napi\_version=7 --node\_abi\_napi=napi --napi\_build\_version=3 --node\_napi\_label=napi-v3' (1)
> \#12 13.86 node-pre-gyp ERR! stack at ChildProcess.\<anonymous\> (/usr/src/app/node\_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
> \#12 13.86 node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20)
> \#12 13.86 node-pre-gyp ERR! stack at maybeClose (internal/child\_process.js:1048:16)
> \#12 13.86 node-pre-gyp ERR! stack at Process.ChildProcess.\_handle.onexit (internal/child\_process.js:288:5)
> \#12 13.86 node-pre-gyp ERR! System Linux 5.10.25-linuxkit
> \#12 13.86 node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/src/app/node\_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
> \#12 13.86 node-pre-gyp ERR! cwd /usr/src/app/node\_modules/bcrypt
> \#12 13.86 node-pre-gyp ERR! node -v v14.15.5
> \#12 13.86 node-pre-gyp ERR! node-pre-gyp -v v1.0.4
> \#12 13.86 node-pre-gyp ERR! not ok 
> \#12 13.86 Failed to execute '/usr/local/bin/node /usr/local/lib/node\_modules/npm/node\_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/src/app/node\_modules/bcrypt/lib/binding/napi-v3/bcrypt\_lib.node --module\_name=bcrypt\_lib --module\_path=/usr/src/app/node\_modules/bcrypt/lib/binding/napi-v3 --napi\_version=7 --node\_abi\_napi=napi --napi\_build\_version=3 --node\_napi\_label=napi-v3' (1)
> \#12 14.17 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node\_modules/fsevents):
> \#12 14.17 npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm64"})
> \#12 14.17 
> \#12 14.24 npm ERR! code ELIFECYCLE
> \#12 14.24 npm ERR! errno 1
> \#12 14.24 npm ERR! bcrypt@5.0.1 install: \`node-pre-gyp install --fallback-to-build\`
> \#12 14.24 npm ERR! Exit status 1
> \#12 14.24 npm ERR! 
> \#12 14.24 npm ERR! Failed at the bcrypt@5.0.1 install script.
> \#12 14.24 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
> 
> I am using mac m1 and basically tried reinstalling whole my setup, I tried different node packages as well. 
> I need to know if this package should not have problem with mac m1 cpu?

See the releases:

> **[Releases · kelektiv/node.bcrypt.js](https://github.com/kelektiv/node.bcrypt.js/releases)**
>
> bcrypt for NodeJs. Contribute to kelektiv/node.bcrypt.js development by creating an account on GitHub.

## Solution

To use the fix, we need to upgrade bcrypt.  
It's currently pinned with a tilde `~5`, meaning the max version is `5.0.1`.  
If this was changed to a caret `^5` then, version `5.1.1` will be installed (any v5.x.x can be installed).

**edit** the meaning of ~ varies depending on how many levels are included in the pin: ~5, ~5.0, ~5.0.1 are different. The current pin of ~5 will allow minor semver upgrades 5.x. The issue here stems from the package.lock file instead of the package.json, where running `npm upgrade` will use the existing pin to upgrade the lock file and solve the issue.

---

<div class="post-metadata">

**Author:** ![Matthew\_White](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/matthew_white/32/1654_2.png) [@Matthew\_White](https://forum.getodk.org/u/Matthew_White)\
**Post date:** [December 21, 2023, 7:38am UTC](https://forum.getodk.org/t/bcrypt-dependency-install-fails-on-arm64-architectures/43992/2 "2023-12-21T07:38:44Z")

</div>

This should be resolved in Central v2023.5, which uses bcrypt 5.1.1. Thank you for making this suggestion!
