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

运行yo @microsoft/sharepoint创建SPFx方案时缺失Extension选项

问题描述
  • 本地运行环境:Node.js 14.18.1 (x64),配套npm包管理工具
  • 操作路径:D:\extensionfullstack
  • 执行创建命令:yo @microsoft/sharepoint 创建SharePoint客户端侧解决方案
    命令执行后的向导交互终端输出如下:
D:\>cd D:\extensionfullstack

D:\extensionfullstack>yo @microsoft/sharepoint

     _-----_     ╭──────────────────────────╮
    |       |    │      Welcome to the      │
    |--(o)--|    │  SharePoint Client-side  │
   `---------´   │         Solution         │
    ( _´U`_ )    │     Generator@1.13.0     │
    /___A___\   /╰──────────────────────────╯
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

Let's create a new SharePoint solution.
? What is your solution name? extensionfullstack
? Only SharePoint Online (latest) is supported.  For earlier versions of SharePoint (2016 and 2019) please use the 1.4.1
 version of the generator. SharePoint Online only (latest)
? Where do you want to place the files? Use the current folder
? Do you want to allow the tenant admin the choice of being able to deploy the solution to all sites immediately without
 running any feature deployment or adding apps in sites? Yes
? Will the components in the solution require permissions to access web APIs that are unique and not shared with other c
omponents in the tenant? Yes
? Which type of client-side component to create?
> WebPart
  • 异常表现:向导推进到「Which type of client-side component to create?(需创建哪类客户端侧组件)」选择环节时,可选列表仅展示WebPart选项,缺失预期存在的Extension选项。
问题根因

该现象是SPFx生成器的正常逻辑过滤,不是安装故障:
你在向导步骤中对 Will the components in the solution require permissions to access web APIs that are unique and not shared with other components in the tenant? (解决方案内组件是否需要访问租户内其他组件不共享的独有Web API权限)选择了Yes,该选项会开启租户级权限隔离模式,该模式下仅支持创建WebPart类型组件,不支持Extension、库组件、自适应卡扩展等其他组件类型,因此生成器会自动过滤掉不兼容的Extension等选项。

解决步骤
  1. 按Ctrl+C终止当前运行的向导进程,删除当前目录下已生成的零散初始化文件
  2. 重新执行yo @microsoft/sharepoint启动创建向导
  3. 走到权限隔离相关问题时,选择No(如果你的Extension确实需要调用专属Web API,可在项目创建完成后手动修改package-solution.json配置权限,不要在初始化向导中开启隔离模式)
  4. 后续推进到组件类型选择环节时,即可看到包含Extension在内的完整组件类型列表。

如果按上述步骤操作后仍看不到完整选项,执行以下命令修复本地生成器环境:

npm uninstall -g @microsoft/generator-sharepoint gulp yo
npm cache clean --force
npm install -g @microsoft/generator-sharepoint@1.13.0 gulp yo

修复完成后重新执行创建命令即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.30 18:03:18