Issue installing better-sqlite3 (macOS)
I have problems installing better-sqlite3 on my machine. I am running up-to-date software (macOS-10.14.2, nodejs-11.11.0, and npm-6.8.0). I uploaded the logs to Pastebin (Terminal, Build Log). I have already tried to build it with earlier versions of said tools (nodejs-10.x and npm-5.10.x), to no avail.
I am a newbie in the nodejs world and I have no idea whether this is really a build issue or whether something is wrong with my local installation.
It looks like you have an incompatible version of python installed. Unfortunately, all Node.js native addons are built with node-gyp which has a dependency of Python 2.7.
Hi,
As the following error message states
npm WARN enoent ENOENT: no such file or directory, open '/Users/seb/package.json'
it seems that you're installing this package in a directory (/Users/seb) where there's no node package inited.
You need to create a package of your own via npm init, preferably in its own directory (i.e., mkdir /Users/seb/myfirstpackage), and then install this package on it.
You can check Creating a package.json file or look up for a tutorial of your choice to start using Node.js.
@ConPac, actually that's just a warning, not an error. It can be safely ignored.
Hey guys, thanks for your help. Unfortunately, the suggestions did not work for me. I selected Python 2.7 as the default, explicitly configured npm to use Python 2.7, and even went so far as to exclude Python 3 from my $PATH. All of that with zero effect on the error message (Current Log).
I'm deeply sorry for my misunderstanding.
@proksch, I think you need to install Xcode and its command line tools, as @JoshuaWise wrote before, after checking the troubleshooting guide and then going to node-gyp's dependencies on macOS. Or maybe you have another libtool interfering with the expected one.
Re-reading carefully your terminal log, it shows these messages:
LIBTOOL-STATIC Release/sqlite3.a
Usage: /opt/local/libexec/gnubin/libtool [OPTION]... [MODE-ARG]...
Try 'libtool --help' for more information.
libtool: error: unrecognised option: '-static'
So your libtool is not the expected one: it lacks an '-static' option. Searching for libtool: error: unrecognised option: '-static shows several issues like yours and resolved using /usr/bin/libtool: check this comment on 'libtool: unrecognized option -static when building'.
Hope it helps.
That, indeed, was the right hint. On my system, I am replacing the command line utils provided by Apple with the regular GNU coreutils (ls and the like) that are also used on Linux systems, because the Apple versions are lacking features. I was not aware that the libtool was part of that.
Fun fact: After switching back the coreutils to default, I could even built better-sqlite3 using Python 3.7.