Nuno Ferrão
Nuno Ferrão

Reputation: 31

Can't get npm and sqlite3 to work on MacOS Catalina

I'm going crazy trying to install the npm package in a project folder (a simple npm install) on my mac as it always leads to errors which are out of my grasp.

It seems some packages are not being successfully installed, and ones which I need for the project I'm working on (sqlite).

I have tried to reinstall node/npm, and I've also tried to reinstall the XCode and the CommandLine Tools as instructed on some debugging posts I found online, but to no avail.

While the error messages have changed, they always seem to block at some specific modules, including the sqlite module.

I have attached the debug report, which I really hope someone more experienced than myself can look at and tell me what I'm doing wrong.

I really wish to start working on projects locally on my mac, but I can't seem to understand what I'm doing wrong.

Thanks a lot in advance for your help.

Here is the error snippet (full log can be found here):

17 warnings and 12 errors generated.
17 warnings and 12 errors generated.
make: *** [Release/obj.target/node_sqlite3/src/database.o] Error 1
make: *** [Release/obj.target/node_sqlite3/src/database.o] Error 1
gyp ERR! build error 
gypgyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
 gyp ERR!ERR! stack      at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
build error 
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3/lib/binding/node-v72-darwin-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3/lib/binding/node-v72-darwin-x64"
gyp ERR! cwd /Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3
gypgyp ERR!  node -v v12.18.2
gyp ERR!ERR!  node-gyp -v v5.1.0
stackgyp  Error: `make` failed with exit code: 2
ERR! gypnot ok 
 ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3/lib/binding/node-v72-darwin-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3/lib/binding/node-v72-darwin-x64"
gyp ERR! cwd /Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3
gyp ERR! node -v v12.18.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
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 build --fallback-to-build --module=/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3/lib/binding/node-v72-darwin-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3/lib/binding/node-v72-darwin-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Darwin 19.6.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3
node-pre-gyp ERR! node -v v12.18.2
node-pre-gyp ERR! node-pre-gyp -v v0.6.38
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3/lib/binding/node-v72-darwin-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3/lib/binding/node-v72-darwin-x64' (1)
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nunoferrao/.npm/_logs/2020-09-08T14_20_29_324Z-debug.log

Regards, Nuno

Upvotes: 0

Views: 2078

Answers (5)

arudzevych
arudzevych

Reputation: 76

I had the same issue after updating to Big Sur. Installing Xcode Command Line Tools helped. For that run

$ xcode-select --install

Upvotes: 1

Jonathan Germain
Jonathan Germain

Reputation: 21

I don't know if you're still looking for answers but I had the same problems on MacOs Big Sur. After updating my npm version with :

npm i -g npm@latest

I had to update my python version on MacOs:

brew install Python

Then my install of sqlite3 has worked.

Upvotes: 2

Nuno Ferr&#227;o
Nuno Ferr&#227;o

Reputation: 31

Thanks a lot for your help.

I didn't manage to solve it through your suggestions but it still pointed me in useful directions. I eventually uninstalled npm again and manually installed all the add-ons subsequently. The command npm install sqlite3 still gave some errors as shown below:

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error getaddrinfo ENOTFOUND mapbox-node-binary.s3.amazonaws.com 
  CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
  LIBTOOL-STATIC Release/nothing.a
  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3310100/sqlite3.c
  TOUCH Release/obj.target/deps/action_before_build.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3310100/sqlite3.o
  LIBTOOL-STATIC Release/sqlite3.a
  CXX(target) Release/obj.target/node_sqlite3/src/backup.o
../src/backup.cc:191:9: warning: unused variable 'status' [-Wunused-variable]
    int status = napi_create_async_work(
        ^
../src/backup.cc:263:5: warning: unused variable 'status' [-Wunused-variable]
    BACKUP_BEGIN(Step);
    ^
../src/macros.h:175:9: note: expanded from macro 'BACKUP_BEGIN'
    int status = napi_create_async_work(                                       \
        ^
../src/backup.cc:329:5: warning: unused variable 'status' [-Wunused-variable]
    BACKUP_BEGIN(Finish);
    ^
../src/macros.h:175:9: note: expanded from macro 'BACKUP_BEGIN'
    int status = napi_create_async_work(                                       \
        ^
3 warnings generated.
  CXX(target) Release/obj.target/node_sqlite3/src/database.o
../src/database.cc:144:9: warning: unused variable 'status' [-Wunused-variable]
    int status = napi_create_async_work(
        ^
../src/database.cc:240:9: warning: unused variable 'status' [-Wunused-variable]
    int status = napi_create_async_work(
        ^
../src/database.cc:557:9: warning: unused variable 'status' [-Wunused-variable]
    int status = napi_create_async_work(
        ^
../src/database.cc:667:9: warning: unused variable 'status' [-Wunused-variable]
    int status = napi_create_async_work(
        ^
4 warnings generated.
  CXX(target) Release/obj.target/node_sqlite3/src/node_sqlite3.o
  CXX(target) Release/obj.target/node_sqlite3/src/statement.o
../src/statement.cc:35:21: warning: result of comparison against a string literal is unspecified (use strncmp instead)
      [-Wstring-compare]
    if (object_type == "Date") {
                    ^  ~~~~~~
../src/statement.cc:37:28: warning: result of comparison against a string literal is unspecified (use strncmp instead)
      [-Wstring-compare]
    } else if (object_type == "RegExp") {
                           ^  ~~~~~~~~
../src/statement.cc:128:9: warning: unused variable 'status' [-Wunused-variable]
    int status = napi_create_async_work(
        ^
../src/statement.cc:188:51: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
    else if (OtherInstanceOf(source.As<Object>(), "RegExp")) {
                                                  ^
../src/statement.cc:209:51: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
    else if (OtherInstanceOf(source.As<Object>(), "Date")) {
                                                  ^
../src/statement.cc:243:87: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
        else if (!info[start].IsObject() || OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[star...
                                                                                      ^
../src/statement.cc:243:142: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
  ...|| OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[start].As<Object>(), "Date") || info[start].I...
                                                                                                         ^
../src/statement.cc:349:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(Bind);
    ^
../src/macros.h:145:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = napi_create_async_work(                                       \
        ^
../src/statement.cc:400:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(Get);
    ^
../src/macros.h:145:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = napi_create_async_work(                                       \
        ^
../src/statement.cc:471:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(Run);
    ^
../src/macros.h:145:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = napi_create_async_work(                                       \
        ^
../src/statement.cc:540:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(All);
    ^
../src/macros.h:145:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = napi_create_async_work(                                       \
        ^
../src/statement.cc:640:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(Each);
    ^
../src/macros.h:145:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = napi_create_async_work(                                       \
        ^
../src/statement.cc:766:5: warning: unused variable 'status' [-Wunused-variable]
    STATEMENT_BEGIN(Reset);
    ^
../src/macros.h:145:9: note: expanded from macro 'STATEMENT_BEGIN'
    int status = napi_create_async_work(                                       \
        ^
../src/statement.cc:243:87: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
        else if (!info[start].IsObject() || OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[star...
                                                                                      ^
../src/statement.cc:337:26: note: in instantiation of function template specialization
      'node_sqlite3::Statement::Bind<node_sqlite3::Statement::Baton>' requested here
    Baton* baton = stmt->Bind<Baton>(info);
                         ^
../src/statement.cc:243:142: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
  ...|| OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[start].As<Object>(), "Date") || info[start].I...
                                                                                                         ^
../src/statement.cc:188:51: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
    else if (OtherInstanceOf(source.As<Object>(), "RegExp")) {
                                                  ^
../src/statement.cc:240:45: note: in instantiation of function template specialization 'node_sqlite3::Statement::BindParameter<int>'
      requested here
                baton->parameters.push_back(BindParameter((array).Get(i), pos));
                                            ^
../src/statement.cc:337:26: note: in instantiation of function template specialization
      'node_sqlite3::Statement::Bind<node_sqlite3::Statement::Baton>' requested here
    Baton* baton = stmt->Bind<Baton>(info);
                         ^
../src/statement.cc:209:51: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
    else if (OtherInstanceOf(source.As<Object>(), "Date")) {
                                                  ^
../src/statement.cc:188:51: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
    else if (OtherInstanceOf(source.As<Object>(), "RegExp")) {
                                                  ^
../src/statement.cc:263:49: note: in instantiation of function template specialization 'node_sqlite3::Statement::BindParameter<const
      char *>' requested here
                    baton->parameters.push_back(BindParameter((object).Get(name),
                                                ^
../src/statement.cc:337:26: note: in instantiation of function template specialization
      'node_sqlite3::Statement::Bind<node_sqlite3::Statement::Baton>' requested here
    Baton* baton = stmt->Bind<Baton>(info);
                         ^
../src/statement.cc:209:51: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
    else if (OtherInstanceOf(source.As<Object>(), "Date")) {
                                                  ^
../src/statement.cc:243:87: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
        else if (!info[start].IsObject() || OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[star...
                                                                                      ^
../src/statement.cc:388:26: note: in instantiation of function template specialization
      'node_sqlite3::Statement::Bind<node_sqlite3::Statement::RowBaton>' requested here
    Baton* baton = stmt->Bind<RowBaton>(info);
                         ^
../src/statement.cc:243:142: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
  ...|| OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[start].As<Object>(), "Date") || info[start].I...
                                                                                                         ^
../src/statement.cc:243:87: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
        else if (!info[start].IsObject() || OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[star...
                                                                                      ^
../src/statement.cc:459:26: note: in instantiation of function template specialization
      'node_sqlite3::Statement::Bind<node_sqlite3::Statement::RunBaton>' requested here
    Baton* baton = stmt->Bind<RunBaton>(info);
                         ^
../src/statement.cc:243:142: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
  ...|| OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[start].As<Object>(), "Date") || info[start].I...
                                                                                                         ^
../src/statement.cc:243:87: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
        else if (!info[start].IsObject() || OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[star...
                                                                                      ^
../src/statement.cc:528:26: note: in instantiation of function template specialization
      'node_sqlite3::Statement::Bind<node_sqlite3::Statement::RowsBaton>' requested here
    Baton* baton = stmt->Bind<RowsBaton>(info);
                         ^
../src/statement.cc:243:142: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
  ...|| OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[start].As<Object>(), "Date") || info[start].I...
                                                                                                         ^
../src/statement.cc:243:87: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
        else if (!info[start].IsObject() || OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[star...
                                                                                      ^
../src/statement.cc:620:30: note: in instantiation of function template specialization
      'node_sqlite3::Statement::Bind<node_sqlite3::Statement::EachBaton>' requested here
    EachBaton* baton = stmt->Bind<EachBaton>(info, 0, last);
                             ^
../src/statement.cc:243:142: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
  ...|| OtherInstanceOf(info[start].As<Object>(), "RegExp") || OtherInstanceOf(info[start].As<Object>(), "Date") || info[start].I...
                                                                                                         ^
27 warnings generated.
  SOLINK_MODULE(target) Release/node_sqlite3.node
  COPY /Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/node_modules/sqlite3/lib/binding/napi-v3-darwin-x64/node_sqlite3.node
  TOUCH Release/obj.target/action_after_build.stamp
npm WARN saveError ENOENT: no such file or directory, open '/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/nunoferrao/Documents/Webdev/Codecademy/capstone-project-1-x-press-publishing/package.json'
npm WARN capstone-project-1-x-press-publishing No description
npm WARN capstone-project-1-x-press-publishing No repository field.
npm WARN capstone-project-1-x-press-publishing No README data
npm WARN capstone-project-1-x-press-publishing No license field.

+ [email protected]
added 113 packages from 137 contributors and audited 211 packages in 42.782s

But eventually installed what I assume is a fallback version.

For now the project code seems to be working (running the js file finally created the sqlite3 database file as intended), so for now it seems its working.

Not sure what the errors and messages in the instalation shown above mean and if I will have more issues down the line, but for now... let's see. Thanks. Nuno

Upvotes: 1

Mr.
Mr.

Reputation: 10102

you probably need to reinstall xcode from app store or via the command line

firstly, check if xcode is installed by executing

$ xcode-select -print-path

this will return the path where xcode is installed, then delete this path if it exists

$ rm -rf $(xcode-select -print-path)

now reinstall xcode by executing

$ xcode-select --install

then install npm modules again by executing

$ npm install

Upvotes: 1

Aga
Aga

Reputation: 1374

It seems like a problem with node-gyp. Try to delete ~/.node-gyp folder and run npm install again. Seems to be pretty helpful as bnoordhuis suggest on github:

Delete your $HOME/.node-gyp directory and try again.

Upvotes: 1

Related Questions