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

VS Code React Native代码片段扩展:README.md图片显示问题求助

解决VS Code扩展README.md图片在Marketplace显示异常的问题

遇到的错误提示:

ERROR Couldn't detect the repository where this extension is published. The image '/images/SnippetDemo1.png' will be broken in README.md. GitHub/GitLab repositories will be automatically detected. Otherwise, please provide the repository URL in package.json or use the --baseContentUrl and --baseImagesUrl options.

以下是三种可行的解决方法:

  • 在package.json中配置仓库地址
    打开扩展根目录的package.json,添加repository字段,示例配置:

    {
      "repository": {
        "type": "git",
        "url": "https://github.com/你的用户名/你的扩展仓库名.git"
      }
    }
    

    配置完成后,Marketplace会自动基于仓库地址解析图片相对路径,原有的![feature X](/images/SnippetDemo1.png)写法即可正常显示图片。

  • 使用图片的绝对URL引用
    将图片上传到GitHub仓库后,复制图片的原始文件链接(比如GitHub上点击图片的「Raw」按钮获取),直接替换相对路径,示例:

    ![feature X](https://raw.githubusercontent.com/你的用户名/你的扩展仓库名/main/images/SnippetDemo1.png)
    

    注意替换链接中的用户名、仓库名和分支名称(如main、master)。

  • 打包时指定baseImagesUrl参数
    使用vsce工具打包扩展时,通过--baseImagesUrl参数指定图片的基础URL,示例命令:

    vsce package --baseImagesUrl https://raw.githubusercontent.com/你的用户名/你的扩展仓库名/main/images/
    

    这样README里的相对路径会自动拼接这个基础URL,无需修改原有图片引用代码。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 17:20:42