node-libpq
node-libpq copied to clipboard
Can't install on Mac Sonoma
I can't install on MacOS 14.4.1 Sonoma. Here is the log of installing my dependencies.
$ pnpm i
... snip ...
.../[email protected]/node_modules/libpq install$ node-gyp rebuild
│ gyp info it worked if it ends with ok
│ gyp info using [email protected]
│ gyp info using [email protected] | darwin | arm64
│ gyp info find Python using Python version 3.12.2 found at "/opt/homebrew/opt/[email protected]/bin/python3.12"
│ gyp info spawn /opt/homebrew/opt/[email protected]/bin/python3.12
│ gyp info spawn args [
│ gyp info spawn args '/Users/johnny/.cache/node/corepack/v1/pnpm/8.14.1/dist/node_modules/node-gyp/gyp/gyp_main…
│ gyp info spawn args 'binding.gyp',
│ gyp info spawn args '-f',
│ gyp info spawn args 'make',
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/johnny/repos/projects/node_modules/.pnpm/[email protected]/nod…
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/johnny/.cache/node/corepack/v1/pnpm/8.14.1/dist/node_modules/node-gyp/addon.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/johnny/Library/Caches/node-gyp/20.12.1/include/node/common.gypi',
│ gyp info spawn args '-Dlibrary=shared_library',
│ gyp info spawn args '-Dvisibility=default',
│ gyp info spawn args '-Dnode_root_dir=/Users/johnny/Library/Caches/node-gyp/20.12.1',
│ gyp info spawn args '-Dnode_gyp_dir=/Users/johnny/.cache/node/corepack/v1/pnpm/8.14.1/dist/node_modules/node-g…
│ gyp info spawn args '-Dnode_lib_file=/Users/johnny/Library/Caches/node-gyp/20.12.1/<(target_arch)/node.lib',
│ gyp info spawn args '-Dmodule_root_dir=/Users/johnny/repos/projects/node_modules/.pnp…
│ gyp info spawn args '-Dnode_engine=v8',
│ gyp info spawn args '--depth=.',
│ gyp info spawn args '--no-parallel',
│ gyp info spawn args '--generator-output',
│ gyp info spawn args 'build',
│ gyp info spawn args '-Goutput_dir=.'
│ gyp info spawn args ]
│ Traceback (most recent call last):
│ File "/Users/johnny/.cache/node/corepack/v1/pnpm/8.14.1/dist/node_modules/node-gyp/gyp/gyp_main.py", line 42, …
│ import gyp # noqa: E402
│ ^^^^^^^^^^
│ File "/Users/johnny/.cache/node/corepack/v1/pnpm/8.14.1/dist/node_modules/node-gyp/gyp/pylib/gyp/__init__.py",…
│ import gyp.input
│ File "/Users/johnny/.cache/node/corepack/v1/pnpm/8.14.1/dist/node_modules/node-gyp/gyp/pylib/gyp/input.py", li…
│ from distutils.version import StrictVersion
│ ModuleNotFoundError: No module named 'distutils'
│ gyp ERR! configure error
│ gyp ERR! stack Error: `gyp` failed with exit code: 1
│ gyp ERR! stack at ChildProcess.onCpExit (/Users/johnny/.cache/node/corepack/v1/pnpm/8.14.1/dist/node_modules…
│ gyp ERR! stack at ChildProcess.emit (node:events:518:28)
│ gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
│ gyp ERR! System Darwin 23.4.0
│ gyp ERR! command "/opt/homebrew/Cellar/node@20/20.12.1/bin/node" "/Users/johnny/.cache/node/corepack/v1/pnpm/8.1…
│ gyp ERR! cwd /Users/johnny/repos/projects/node_modules/.pnpm/[email protected]/node_modules/…
│ gyp ERR! node -v v20.12.1
│ gyp ERR! node-gyp -v v9.4.1
│ gyp ERR! not ok
└─ Failed in 168ms at /Users/johnny/repos/projects/node_modules/.pnpm/[email protected]/node_modules/libpq
I guess the issue is ModuleNotFoundError: No module named 'distutils' and it seems to be related the default python on mac.
Is there anything I can do to install distutils? I have no real experience with python.
Installed distutils with brew install python-setuptools and now it works. Although it doesn't seem to be the best fix.