安装@storybook/aem依赖时node-gyp报错求助
Fixing node-gyp Error When Installing @storybook/aem in AEM ui.frontend
Hey Kaushik, that node-gyp error you're hitting is super common when installing native Node.js modules (like node-expat, a dependency of @storybook/aem) on Windows. Let's break down how to fix it step by step:
Why This Happens
node-expat requires compiling native C++ code, and node-gyp (the tool Node uses for this task) can't find a valid Visual Studio installation with the required C++ build tools. Your error log explicitly points out it's missing the "Desktop development with C++" workload.
Step-by-Step Solutions
1. Install Visual Studio with the Required Workload
This is the most reliable fix:
- Download Visual Studio 2019 or 2022 (both work perfectly with your Node v10.21.0)
- When running the installer, make sure to check the "Desktop development with C++" workload — this includes the MSVC compiler, Windows SDK, and all other tools node-gyp needs to compile native modules
- Let the installer finish, then restart your computer to ensure all environment variables are properly set
2. Run the Install Command in the VS Native Tools Prompt
After setting up Visual Studio:
- Open the "x64 Native Tools Command Prompt for VS [Your Version]" (you'll find this in the Start Menu under your Visual Studio folder)
- Navigate to your
ui.frontenddirectory - Re-run
npm install @storybook/aem --save-dev
This prompt automatically configures all the environment variables node-gyp requires, so it'll detect your VS installation without extra setup.
3. Alternative: Use windows-build-tools (No Full VS Install)
If you don't want to install the entire Visual Studio IDE:
- Open Command Prompt as Administrator
- Run
npm install --global windows-build-tools - This tool will automatically install the minimal VS Build Tools and Python 2.7 (which node-gyp requires for older Node versions like v10)
- Once installed, restart your command line and try the npm install again
Quick Troubleshoot Check
If you're still stuck, double-check these settings:
- Run
npm config get msvs_versionto confirm it's set to your installed VS version (e.g.,2019) - If not, set it manually with
npm config set msvs_version 2019(replace with your actual VS version)
内容的提问来源于stack exchange,提问作者kdatta
相关产品推荐
相关产品推荐

