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

使用NPM安装Parcel时遭遇gyp错误求助

安装Parcel时node-gyp错误的解决方法

问题背景

尝试通过NPM和Yarn安装Parcel,先后更换Node.js 14、16、10多个版本,均未解决问题,始终出现相同的gyp错误。使用环境为Windows 10 32位系统,已安装Python。

具体错误信息

gyp info it worked if it ends with ok
gyp info using node-gyp@8.2.0
gyp info using node@16.13.0 | win32 | ia32
gyp info find Python using Python version 3.11.0 found at "C:\Users\ALI\AppData\Local\Programs\Python\Python311-32\python.exe" 
gyp info find VS using VS2017 (15.9.28307.1831) found at:
gyp info find VS "C:\Program Files\Microsoft Visual Studio\2017\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Users\ALI\AppData\Local\Programs\Python\Python311-32\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\ALI\\Desktop\\osamasoliman\\node_modules\\msgpackr-extract\\build\\config.gypi',       
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\ALI\\AppData\\Local\\node-gyp\\Cache\\16.13.0\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\ALI\\AppData\\Local\\node-gyp\\Cache\\16.13.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\ALI\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.13.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\ALI\\Desktop\\osamasoliman\\node_modules\\msgpackr-extract',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\Users\\ALI\\Desktop\\osamasoliman\\node_modules\\msgpackr-extract\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp: C:\Users\ALI\AppData\Local\node-gyp\Cache\16.13.0\common.gypi not found (cwd: C:\Users\ALI\Desktop\osamasoliman\node_modules\msgpackr-extract) while reading includes of binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:353:16)
gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Windows_NT 10.0.19044
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\ALI\Desktop\osamasoliman\node_modules\msgpackr-extract
gyp ERR! node -v v16.13.0
gyp ERR! node-gyp -v v8.2.0
gyp ERR! not ok"
info This module is OPTIONAL, you can safely ignore this error
PS C:\Users\ALI\Desktop\osamasoliman> 

解决方法

1. 修复缺失的common.gypi文件

错误核心是*C:\Users\ALI\AppData\Local\node-gyp\Cache\16.13.0\common.gypi文件缺失*,可通过以下方式处理:

  • 删除C:\Users\ALI\AppData\Local\node-gyp\Cache\16.13.0整个目录,重新运行Parcel安装命令,让node-gyp自动重新下载缓存文件。
  • 或打开管理员权限的命令提示符,执行:
    node-gyp configure --verbose
    
    手动触发缓存文件生成。

2. 调整Python版本

node-gyp@8.2.0与Python 3.11兼容性可能存在问题,建议降级到Python 3.9或3.10版本,安装完成后用命令指定Python路径:

npm config set python "C:\Users\ALI\AppData\Local\Programs\Python\Python39-32\python.exe"

3. 确认Visual Studio Build Tools配置

确保VS2017 Build Tools安装了完整的C++开发组件:

  • 打开VS Installer,勾选“Desktop development with C++”,包含MSVC编译器、Windows SDK等必要组件。
  • 执行命令指定VS版本:
    npm config set msvs_version 2017
    

4. 跳过可选依赖安装

错误提示明确该模块为可选组件,可直接忽略错误或安装时跳过:

  • NPM安装命令:
    npm install parcel --ignore-optional
    
  • Yarn安装命令:
    yarn add parcel --ignore-optional
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 11:20:29