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

使用Teams Toolkit v5.8.1部署Bot应用时因node-fetch版本缺失失败

解决Teams Toolkit部署Bot到Azure时node-fetch@^2.6.7版本缺失问题

问题描述

使用VSCode Teams Toolkit v5.8.1创建连接Azure Function App的Bot应用,点击「在Teams中调试」或「在测试工具中调试」启动调试时,Azure部署失败,核心报错为找不到node-fetch@^2.6.7版本,导致依赖安装流程中断。关键报错日志如下:

[2024-08-09T11:14:55.162Z] [Info] - Executing deploy 

Lifecycle stage: deploy(3 step(s) in total). The following actions will be executed: 
(1/3) Action devTool/install: installing dependencies
(2/3) Action cli/runNpmCommand(install dependencies): running npm command.
(3/3) Action file/createOrUpdateEnvironmentFile: Create or update variables to environment file.

[2024-08-09T11:14:55.162Z] [Info] - Executing lifecycle deploy
[2024-08-09T11:15:41.109Z] [Warning] -  [script stderr] npm error code ETARGET

[2024-08-09T11:15:41.110Z] [Warning] -  [script stderr] npm error notarget No matching version found for node-fetch@^2.6.7.
npm error notarget In most cases you or one of your dependencies are requesting
npm error notarget a package version that doesn't exist.

[2024-08-09T11:15:41.125Z] [Error] - Failed to Execute lifecycle deploy due to failed action: {"name":"install dependencies","uses":"cli/runNpmCommand"}. ScriptExecutionError:Unable to execute script action.. Env output: {}

解决方案

1. 清理npm缓存并切换官方源

node-fetch@^2.6.7是官方仓库存在的稳定版本,问题大概率源于npm缓存损坏或第三方镜像源同步延迟:

  • 清理本地npm缓存:
    npm cache clean --force
    
  • 切换到npm官方源(若当前使用第三方镜像):
    npm config set registry https://registry.npmjs.org/
    
  • 手动执行依赖安装验证:
    npm install
    
    安装成功后重新启动Teams Toolkit的调试部署流程。

2. 强制覆盖node-fetch版本

如果是项目间接依赖的包请求了异常版本,可在package.json中添加版本强制覆盖规则:
打开项目根目录的package.json,在根节点插入如下配置:

"overrides": {
  "node-fetch": "^2.7.0"
}

^2.7.0是2.6.7的兼容升级版本,完全满足依赖需求。添加后执行npm install,再重新触发部署。

3. 更新Teams Toolkit并重建项目

若问题源于模板依赖配置缺陷:

  • 在VSCode扩展商店将Teams Toolkit更新至最新版本
  • 删除现有项目,使用最新模板重新创建连接Function App的Bot应用,再尝试调试部署

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 01:20:55