使用npx创建Strapi应用时遭遇安装错误,请求技术协助
Strapi应用创建失败问题分析与解决方案
执行npx create-strapi-app@latest my-project --quickstart创建Strapi应用时多次失败,表现为依赖安装环节卡顿或直接失败,伴随模块废弃提示及编译错误,具体信息如下:
依赖安装警告信息
以下为依赖包的废弃/遗留提示,暂时不影响应用核心运行,但建议后续版本迭代时跟进处理:
@strapi/strapi > koa-session > uuid@3.4.0:需升级至7及以上版本,旧版本部分场景使用Math.random()存在安全风险@strapi/strapi > koa-body > formidable@1.2.6:需升级至formidable v2或v3版本@strapi/strapi > @strapi/admin > react-router > mini-create-react-context@0.4.1:该包已停止维护@strapi/strapi > @strapi/admin > node-polyfill-webpack-plugin > url > querystring@0.2.0:querystring API为遗留API,建议使用URLSearchParams替代@strapi/strapi > @strapi/plugin-email > @strapi/provider-email-sendmail > sendmail > mailcomposer@3.12.0:项目已无人维护@strapi/strapi > @strapi/plugin-email > @strapi/provider-email-sendmail > sendmail > mailcomposer > buildmail@3.10.0:项目已无人维护@strapi/strapi > @strapi/generators > plop > liftoff > findup-sync > micromatch > snapdragon > source-map-resolve@0.5.3:该包已废弃@strapi/strapi > @strapi/generators > plop > liftoff > findup-sync > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1:该包已废弃@strapi/strapi > @strapi/generators > plop > liftoff > findup-sync > micromatch > snapdragon > source-map-resolve > urix@0.1.0:该包已废弃@strapi/strapi > @strapi/generators > plop > liftoff > findup-sync > micromatch > snapdragon > source-map-resolve > source-map-url@0.4.1:该包已废弃@strapi/plugin-users-permissions > request@2.88.2:request已废弃@strapi/plugin-users-permissions > request > uuid@3.4.0:需升级至7及以上版本,旧版本部分场景使用Math.random()存在安全风险@strapi/plugin-users-permissions > request > har-validator@5.1.5:该库已停止维护@strapi/plugin-users-permissions > @strapi/helper-plugin@4.5.0:存在未满足的对等依赖webpack@^5.74.0
核心失败原因
安装better-sqlite3时编译失败,根源是Windows平台缺少C++编译环境,具体错误日志:
错误 C:\Users\adity\OneDrive\Desktop\my-pro\node_modules\better-sqlite3:命令执行失败。 退出码:1 命令:prebuild-install || npm run build-release 输出: prebuild-install warn install 未找到预构建二进制文件(target=18.12.0 runtime=node arch=x64 libc= platform=win32) > better-sqlite3@7.4.6 build-release > node-gyp rebuild --release gyp info 执行成功会以ok结尾 gyp info 使用 node-gyp@9.1.0 gyp info 使用 node@18.12.0 | win32 | x64 gyp info 找到Python版本3.11.0,路径为"C:\Users\adity\AppData\Local\Programs\Python\Python311\python.exe" gyp ERR! find VS gyp ERR! find VS 未通过命令行或npm配置设置msvs_version gyp ERR! find VS 未设置VCINSTALLDIR,未在VS命令提示符中运行 gyp ERR! find VS 无法使用PowerShell找到Visual Studio 2017或更高版本 gyp ERR! find VS 查找Visual Studio 2015 - 未找到 gyp ERR! find VS 不再查找VS2013,因为它仅支持Node.js 8及以下版本 gyp ERR! find VS 您需要安装最新版本的Visual Studio,包含"Desktop development with C++"工作负载。 gyp ERR! configure error gyp ERR! stack Error: 无法找到任何可用的Visual Studio安装
解决方案
方案1:配置C++编译环境
- 下载安装Visual Studio 2017或更高版本(推荐最新稳定版)
- 安装过程中必须勾选**Desktop development with C++**工作负载,确保包含C++编译器、Windows SDK等核心组件
- 安装完成后,重启终端并进入项目目录,执行以下命令重新安装依赖:
或使用npm:cd C:\Users\adity\OneDrive\Desktop\my-pro && yarn installcd C:\Users\adity\OneDrive\Desktop\my-pro && npm install
方案2:更换数据库类型
若不想配置C++环境,可在创建Strapi应用时选择无需本地编译的数据库(如PostgreSQL、MySQL):
- 执行命令:
npx create-strapi-app@latest my-project - 选择自定义配置,按提示指定非SQLite的数据库类型及连接信息,跳过better-sqlite3的安装。
内容的提问来源于stack exchange,提问作者Aditya Kumar
相关产品推荐
相关产品推荐

