【问题标题】:how to fix npm install sqlite3 error on mac?如何修复 Mac 上的 npm install sqlite3 错误?
【发布时间】:2022-01-08 17:41:01
【问题描述】:

我正在尝试在 mac 上使用 npm 安装 sqlite3,但是出现以下错误

npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated node-pre-gyp@0.11.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm ERR! code 1
npm ERR! path /Users/ryan/Desktop/12SDE/Formative-1/node_modules/sqlite3
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/ryan/Desktop/12SDE/Formative-1/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/ryan/Desktop/12SDE/Formative-1/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@0.11.0
npm ERR! node-pre-gyp info using node@16.13.1 | darwin | arm64
npm ERR! node-pre-gyp WARN Using request for node-pre-gyp https download 
npm ERR! node-pre-gyp info build requesting source compile
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.13.1 | darwin | arm64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.3.0
npm ERR! gyp info using node@16.13.1 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.10.0 found at "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3"
npm ERR! gyp info spawn /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/ryan/Desktop/12SDE/Formative-1/node_modules/sqlite3/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/ryan/Library/Caches/node-gyp/16.13.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/ryan/Library/Caches/node-gyp/16.13.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/ryan/Library/Caches/node-gyp/16.13.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/ryan/Desktop/12SDE/Formative-1/node_modules/sqlite3',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
npm ERR! 
npm ERR! No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
npm ERR! 
npm ERR! No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
npm ERR! 
npm ERR! Traceback (most recent call last):
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1502, in XcodeVersion
npm ERR!     version_list = GetStdoutQuiet(["xcodebuild", "-version"]).splitlines()
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1563, in GetStdoutQuiet
npm ERR!     raise GypError("Error %d running %s" % (job.returncode, cmdlist[0]))
npm ERR! gyp.common.GypError: Error 1 running xcodebuild
npm ERR! 
npm ERR! During handling of the above exception, another exception occurred:
npm ERR! 
npm ERR! Traceback (most recent call last):
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 45, in <module>
npm ERR!     sys.exit(gyp.script_main())
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 662, in script_main
npm ERR!     return main(sys.argv[1:])
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 654, in main
npm ERR!     return gyp_main(args)
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 639, in gyp_main
npm ERR!     generator.GenerateOutput(flat_list, targets, data, params)
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2455, in GenerateOutput
npm ERR!     writer.Write(
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 798, in Write
npm ERR!     self.WriteActions(
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 932, in WriteActions
npm ERR!     env = self.GetSortedXcodeEnv()
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2108, in GetSortedXcodeEnv
npm ERR!     return gyp.xcode_emulation.GetSortedXcodeEnv(
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1888, in GetSortedXcodeEnv
npm ERR!     env = _GetXcodeEnv(
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1743, in _GetXcodeEnv
npm ERR!     "XCODE_VERSION_ACTUAL": XcodeVersion()[0],
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1513, in XcodeVersion
npm ERR!     version = CLTVersion()  # macOS Catalina returns 11.0.0.0.1.1567737322
npm ERR!   File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1551, in CLTVersion
npm ERR!     return re.search(regex, output).groupdict()["version"]
npm ERR! AttributeError: 'NoneType' object has no attribute 'groupdict'
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 20.6.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/ryana/Desktop/12SDE/Formative-1/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/ryan/Desktop/12SDE/Formative-1/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
npm ERR! gyp ERR! cwd /Users/ryan/Desktop/12SDE/Formative-1/node_modules/sqlite3
npm ERR! gyp ERR! node -v v16.13.1
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok 
npm ERR! node-pre-gyp ERR! build error 
npm ERR! 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 configure --fallback-to-build --module=/Users/ryan/Desktop/12SDE/Formative-1/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/ryan/Desktop/12SDE/Formative-1/node_modules/sqlite3/lib/binding/napi-v3-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/ryan/Desktop/12SDE/Formative-1/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System Darwin 20.6.0
npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/ryan/Desktop/12SDE/Formative-1/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/ryan/Desktop/12SDE/Formative-1/node_modules/sqlite3
npm ERR! node-pre-gyp ERR! node -v v16.13.1
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v0.11.0
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ryan/.npm/_logs/2021-12-02T07_55_52_766Z-debug.log

我不确定该怎么做,因为它促使我​​下载 xcode 开发人员的东西。我必须下载它还是有解决此错误的解决方案。

  • 节点版本v16.13.1
  • npm 版本 8.1.2
  • 使用的命令npm install sqlite3
  • sqlite3 版本 3.32.3

【问题讨论】:

  • 你能提供更多关于你的环境和你用来安装 sqlit3 的 npm 命令的信息吗?
  • 我使用的node版本是v16.13.1
  • 我使用的npm版本是8.1.2
  • 我使用的命令是 - npm install sqlite3
  • 我安装的sqlite3版本是3.32.3

标签: node.js sqlite npm-install node-sqlite3


【解决方案1】:

在 npm 中似乎没有 3.32.3 版本。 npm 版本控制与 sqlite3 的版本不同。

但如果我尝试通过 npm 安装任何 3.x.x 版本,我会遇到类似的错误。

但我也可以通过 npm 安装 sqlite3@4.2.0 和 sqlite@5.0.2。

Here you can find the version history for the sqlite3 npm package

编辑: 如果您的系统上没有安装 sqlite3,则当前版本的 npm sqlite3 包(编写时间为 5.0.2)将ship sqlite 3.32.3 internaly

也许你必须清理你的 npm 缓存或卸载你本地的 sqlite3 版本才能从 npm 安装 sqlite3 包?

【讨论】:

  • 你如何找到 npm sqlite 的版本,因为我所说的版本是我笔记本电脑上安装的版本
  • 使用npm list -g --depth 0 | grep sqlite 检查全局安装版本。使用npm list --depth 0 | grep sqlite 检查项目特定版本。如果您安装了全局版本,请将其卸载。除此之外,我只能猜测你机器上本地安装的 sqlite3 会干扰 npm 包附带的 sqlite3 版本。
猜你喜欢
  • 2021-01-14
  • 2017-10-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-05
  • 2018-12-28
  • 1970-01-01
  • 2020-06-26
相关资源
最近更新 更多