You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装Node.js与VS Community后npm install报错的解决咨询

解决npm install时node-gyp编译lmdb-store失败的问题

问题场景

安装Node.js v19.2.0和Visual Studio Community 2022后,执行npm install时出现node-gyp编译失败错误,核心错误信息如下:

npm ERR! gyp ERR! cwd C:\Users\HP\Desktop\ZTM\simplefolio\node_modules\lmdb-store
npm ERR! gyp ERR! node -v v19.2.0
npm ERR! gyp ERR! node-gyp -v v9.3.0
npm ERR! gyp ERR! not ok

已尝试卸载重装Node.js,问题仍存在。

解决步骤

1. 补全Visual Studio 2022编译组件

  • 打开Visual Studio Installer,选择「修改」你的Community 2022实例
  • 必须勾选**「桌面开发使用C++」**工作负载,确保包含:
    • MSVC v142+生成工具
    • 对应Windows 10.0.19044版本的Windows SDK
  • 可选勾选**「Node.js开发」**工作负载,帮助node-gyp自动识别编译环境
  • 安装完成后重启电脑

2. 配置node-gyp环境变量

以管理员身份打开命令提示符,执行以下命令:

npm config set msvs_version 2022
npm config set python python3

注:若系统仅安装Python 2.7,将python3改为python即可

3. 清理缓存后重新安装

# 删除项目依赖文件夹和锁文件
rmdir /s /q node_modules
del package-lock.json

# 清理npm缓存
npm cache clean --force

# 重新执行安装
npm install

4. 降级Node.js至LTS版本

Node 19为非LTS版本,可能与部分原生模块兼容性不佳:

  • 使用nvm-windows管理版本,安装后执行:
nvm install 18.12.1
nvm use 18.12.1
  • 切换版本后再次执行npm install

5. 强制使用预编译版本安装lmdb-store

若上述方法无效,尝试跳过本地编译,直接安装预编译包:

npm install lmdb-store --build-from-source=false

内容的提问来源于stack exchange,提问作者Aksha jain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 15:10:37