blog
blog copied to clipboard
Getting node-odbc working on Mac M1/arm64 (without Rosetta)
- Install brew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”- Latest at https://brew.sh/
- Install unixodbc:
brew install unixodbc - Download app package from IBM: https://www.ibm.com/support/pages/ibm-i-access-client-solutions
- Since it’s not made for arm64 (m1) yet, we need to change the .pkg file manually.
pkgutil --expand ibm-iaccess-1.1.0.15.pkg ./out- Edit
./out/Distrubution. ChangehostArchitectures="x86_64”tohostArchitectures="x86_64,arm64” pkgutil --flatten ./out ./ibm.pkg- In the future, IBM will fix this so you don't have to change it.
- Run the newly created
ibm.pkg- You should not see the warning about Rosetta not being installed.
- You should not see the warning about unixodbc missing. If you did, you did something wrong.
Actually compiling node-odic:
I had to make two updates to the binding.gyp to make ODBC actually compile from npm i (yarn)
[ 'OS == "mac"', {
'include_dirs': [
'/usr/local/include',
'/opt/homebrew/include'
],
'libraries' : [
'-L/usr/local/lib',
'-L/opt/homebrew/lib',
'-lodbc'
],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS', 'NAPI_EXPERIMENTAL' ]
}],
Installing and compiling odbc with npm/yarn has to be done in two separate steps.
- Remove
odbcfrom your package npm ioryarnto install the rest of your packagesnpm i odbc@x —ignore-scriptsoryarn add odbc@x —ignore-scriptsto install node-odbc without compiling- Make the change to the
binding.gypfile in./node_modules/odbcto make the build work for the m1. - Run
npm run installto build ODBC for your app.
These steps will likely be redundant when node-odbc is updated to work on m1/arm64
You saved my life, thanks!
Looks like support has since been added to node-odbc in version 2.4.6 https://github.com/markdirish/node-odbc/commit/286de6ec624e5da4a79b1d93dee003c1e123cd32