本地运行Slack Deno Hello-World模板报sdk_hook_invocation_failed错误
问题:运行Slack Deno Hello-World模板时
slack dev失败 我尝试在本地运行Slack Hello-World模板项目,执行slack dev命令时失败并抛出以下错误:
$ slack dev ? Choose a local environment Install to a new workspace ? Pick a workspace for the app example-tech T01234NFT Not installed 🔔 If you leave this workspace, you can no longer manage the installed apps Installed apps will belong to the workspace if you leave the workspace Updating local app install for workspace "Tech" error: Uncaught (in promise) TypeError: TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'. 'Deno.utime' is an unstable API. Did you forget to run with the '--unstable' flag? await Deno.utime(dest, statInfo.atime, statInfo.mtime); ~~~~~ at https://deno.land/std@0.67.0/fs/copy.ts:92:16 TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'. 'Deno.utimeSync' is an unstable API. Did you forget to run with the '--unstable' flag? Deno.utimeSync(dest, statInfo.atime, statInfo.mtime); ~~~~~~~~~ at https://deno.land/std@0.67.0/fs/copy.ts:103:10 TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'. 'Deno.utime' is an unstable API. Did you forget to run with the '--unstable' flag? await Deno.utime(dest, statInfo.atime, statInfo.mtime); ~~~~~ at https://deno.land/std@0.67.0/fs/copy.ts:127:16 TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'. 'Deno.utimeSync' is an unstable API. Did you forget to run with the '--unstable' flag? Deno.utimeSync(dest, statInfo.atime, statInfo.mtime); ~~~~~~~~~ at https://deno.land/std@0.67.0/fs/copy.ts:152:10 TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'. 'Deno.utime' is an unstable API. Did you forget to run with the '--unstable' flag? await Deno.utime(dest, srcStatInfo.atime, srcStatInfo.mtime); ~~~~~ at https://deno.land/std@0.67.0/fs/copy.ts:172:16 TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'. 'Deno.utimeSync' is an unstable API. Did you forget to run with the '--unstable' flag? Deno.utimeSync(dest, srcStatInfo.atime, srcStatInfo.mtime); ~~~~~~~~~ at https://deno.land/std@0.67.0/fs/copy.ts:200:10 Found 6 errors. const functionModule = await import(`file://${functionFilePath}`); ^ at async getDefaultExport (https://deno.land/x/deno_slack_hooks@1.0.1/utilities.ts:27:26) at async readImportedManifestFile (https://deno.land/x/deno_slack_hooks@1.0.1/get_manifest.ts:114:20) at async getManifest (https://deno.land/x/deno_slack_hooks@1.0.1/get_manifest.ts:30:22) at async getValidateAndCleanManifest (https://deno.land/x/deno_slack_hooks@1.0.1/get_manifest.ts:129:29) at async https://deno.land/x/deno_slack_hooks@1.0.1/get_manifest.ts:136:26 Check /home/ms/.slack/logs/slack-debug-20230531.log for full error logs 🚫 Error: Unable to get your app manifest details. Please check your manifest file: Command for 'GetManifest' returned an error: exit status 1 (sdk_hook_invocation_failed) Suggestion: Try to run `slack doctor` to check that your system dependencies are up-to-date.
执行slack doctor未检测到任何问题,输出如下:
$ slack doctor SYSTEM ✔ Operating System (resource allocation manager) Version: linux (amd64) ✔ Deno (a JavaScript runtime) Version: v1.20.6 Recommendation: We suggest using the latest version of Deno ✔ Git (a version control system) Version: git version 2.34.1 SLACK ✔ CLI (this tool for building Slack apps) Version: 2.2.0 ✔ Configurations (any adjustments to settings) Last updated: 2023-05-30 16:31:27 +02:00 ✔ Credentials (your Slack authentication) Team domain: example-tech Team ID: T01234NFT User ID: U21234NFT Last updated: 2023-05-31 11:00:56 +02:00 Token status: Valid PROJECT ✔ Dependencies (requisites for development) deno_slack_hooks: 1.0.1 deno_slack_sdk: 2.1.2 deno_slack_api: 2.1.0 Errors: 0
问题原因与解决方法
原因
核心问题是依赖版本不兼容:
- 项目依赖的
deno_slack_hooks@1.0.1使用了非常老旧的Deno标准库版本(deno.land/std@0.67.0,发布于2020年),该版本依赖的Deno.utime/Deno.utimeSync是当时的不稳定API。 - 你当前使用的Deno版本是v1.20.6,在这个版本中,这些旧的不稳定API已经被调整(要么重命名、要么移除、要么移动到其他命名空间),导致旧版标准库无法找到对应方法。
解决方法
升级Deno到最新稳定版
执行命令完成升级:deno upgrade新版Deno会兼容更现代的依赖版本,同时修复旧版本的API兼容问题。
更新项目的Slack SDK依赖版本
修改项目根目录的import_map.json,将依赖更新为最新稳定版(版本号可根据实际情况调整):{ "imports": { "deno_slack_hooks/": "https://deno.land/x/deno_slack_hooks@1.3.0/", "deno_slack_sdk/": "https://deno.land/x/deno_slack_sdk@2.9.0/", "deno_slack_api/": "https://deno.land/x/deno_slack_api@2.3.0/" } }新版本的Slack SDK会使用兼容新版Deno的标准库版本,避免旧API的调用问题。
清理Deno缓存并重新加载依赖
执行命令清除旧缓存,确保加载更新后的依赖:deno cache --reload
完成以上步骤后,重新执行slack dev即可正常运行项目。
内容的提问来源于stack exchange,提问作者Michal_Szulc
相关产品推荐
相关产品推荐

