Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting node-odbc working on Mac M1/arm64 (without Rosetta) #51

Open
worksofliam opened this issue Sep 6, 2021 · 2 comments
Open

Getting node-odbc working on Mac M1/arm64 (without Rosetta) #51

worksofliam opened this issue Sep 6, 2021 · 2 comments
Labels
nodejs Node.js topics odbc Stuff about ODBC

Comments

@worksofliam
Copy link
Owner

  1. Install brew:
    • /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”
    • Latest at https://brew.sh/
  2. Install unixodbc: brew install unixodbc
  3. Download app package from IBM: https://www.ibm.com/support/pages/ibm-i-access-client-solutions
  4. Since it’s not made for arm64 (m1) yet, we need to change the .pkg file manually.
    1. pkgutil --expand ibm-iaccess-1.1.0.15.pkg ./out
    2. Edit ./out/Distrubution. Change hostArchitectures="x86_64” to hostArchitectures="x86_64,arm64”
    3. pkgutil --flatten ./out ./ibm.pkg
    4. In the future, IBM will fix this so you don't have to change it.
  5. Run the newly created ibm.pkg
    1. You should not see the warning about Rosetta not being installed.
    2. 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.

  1. Remove odbc from your package
  2. npm i or yarn to install the rest of your packages
  3. npm i odbc@x —ignore-scripts or yarn add odbc@x —ignore-scripts to install node-odbc without compiling
  4. Make the change to the binding.gyp file in ./node_modules/odbc to make the build work for the m1.
  5. Run npm run install to build ODBC for your app.

These steps will likely be redundant when node-odbc is updated to work on m1/arm64

@worksofliam worksofliam added nodejs Node.js topics odbc Stuff about ODBC labels Sep 6, 2021
@worksofliam worksofliam changed the title Getting node-odbc working on Mac M1/arm64 Getting node-odbc working on Mac M1/arm64 (without Rosetta) Sep 6, 2021
@ilpredo
Copy link

ilpredo commented Apr 15, 2022

You saved my life, thanks!

@thealexbaron
Copy link

Looks like support has since been added to node-odbc in version 2.4.6 IBM/node-odbc@286de6e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nodejs Node.js topics odbc Stuff about ODBC
Projects
None yet
Development

No branches or pull requests

3 participants