【问题标题】:Can't get npm and sqlite3 to work on MacOS Catalina无法让 npm 和 sqlite3 在 MacOS Catalina 上工作
【发布时间】:2020-12-26 23:29:45
【问题描述】:

尝试在我的 Mac 上的项目文件夹(简单的 npm install)中安装 npm 包我快疯了,因为它总是会导致我无法掌握的错误。

似乎有些软件包没有成功安装,而我正在处理的项目(sqlite)需要这些软件包。

我已尝试重新安装 node/npm,并且我还尝试按照我在网上找到的一些调试帖子中的说明重新安装 XCode 和命令行工具,但无济于事。

虽然错误消息已更改,但它们似乎总是在某些特定模块上阻塞,包括 sqlite 模块。

我附上了调试报告,我真的希望比我更有经验的人可以看看并告诉我我做错了什么。

我真的很想开始在我的 Mac 上本地处理项目,但我似乎无法理解我做错了什么。

非常感谢您的帮助。

这里是错误sn-p(完整日志可以找到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 x-press-publishing@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3@3.1.13 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sqlite3@3.1.13 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

问候, 努诺

【问题讨论】:

  • 请指定您要安装的库,例如 npm install react 您是如何运行安装命令的,也可能某些 npm 库是作用域库,也许您的 npm 全局配置配置不同.

标签: javascript macos sqlite npm node-modules


【解决方案1】:

这似乎是 node-gyp 的问题。尝试删除 ~/.node-gyp 文件夹并再次运行 npm install。正如 bnoordhuis 在github 上建议的那样,似乎很有帮助:

删除您的 $HOME/.node-gyp 目录并重试。

【讨论】:

    【解决方案2】:

    您可能需要从app store 或通过命令行重新安装xcode

    首先,通过执行检查xcode是否安装

    $ xcode-select -print-path
    

    这将返回安装xcode的路径,如果存在则删除该路径

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

    现在通过执行重新安装 xcode

    $ xcode-select --install
    

    然后通过执行再次安装 npm 模块

    $ npm install
    

    【讨论】:

    • 您好,感谢您的帮助。我试过了,但它说 xcode 包已经安装:Nunos-MBP:~ nunoferrao$ xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" to install updates
    【解决方案3】:

    我不知道您是否还在寻找答案,但我在 MacOs Big Sur 上遇到了同样的问题。 更新我的 npm 版本后:

    npm i -g npm@latest
    

    我必须在 MacOs 上更新我的 python 版本:

    brew install Python
    

    那么我安装的 sqlite3 就成功了。

    【讨论】:

      【解决方案4】:

      更新到 Big Sur 后我遇到了同样的问题。安装 Xcode 命令行工具有帮助。对于那次运行

      $ xcode-select --install

      【讨论】:

        【解决方案5】:

        非常感谢您的帮助。

        我没有通过您的建议解决它,但它仍然为我指明了有用的方向。我最终再次卸载了 npm 并随后手动安装了所有附加组件。命令npm install sqlite3还是报错如下:

        node-pre-gyp WARN Using request for node-pre-gyp https download 
        node-pre-gyp WARN Pre-built binaries not installable for sqlite3@5.0.0 and node@12.18.3 (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.
        
        + sqlite3@5.0.0
        added 113 packages from 137 contributors and audited 211 packages in 42.782s
        

        但最终安装了我认为是后备版本。

        目前项目代码似乎正在运行(运行 js 文件最终按预期创建了 sqlite3 数据库文件),所以目前看来它正在运行。

        不确定上面显示的安装中的错误和消息是什么意思,以及我是否会遇到更多问题,但现在......让我们看看。 谢谢。 努诺

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2020-02-04
          • 2020-02-08
          • 2020-11-30
          • 2021-01-16
          • 2020-04-23
          • 2020-07-04
          • 1970-01-01
          相关资源
          最近更新 更多