首页 > 解决方案 > 使用 React.js 的 Chrome 扩展程序导致“清单文件丢失或无法读取”错误

问题描述

Manifest file is missing or unreadable尝试加载解压的 Chrome 扩展程序时遇到错误。我将扩展构建为一个反应应用程序,因此文件结构如下所示:

在此处输入图像描述

我知道manifest.json需要在根文件夹中,而不是public通常反应的方式。但是,当我将其移至根目录时,它会中断与我的连接,并且我的弹出窗口仅在未连接任何 javascript 的情况app.js下加载。index.html

这就是我的清单的布局方式:

{
  "manifest_version": 2,

  "name": "My Extension",
  "description": "This extension is a starting point to create a real Chrome extension",
  "version": "0.0.1",

  "browser_action": {
    "default_popup": "index.html",
    "default_title": "Open the popup"
  },
  "icons": {
    "16": "/public/images/get_started16.png",
    "48": "/public/images/get_started48.png",
    "128": "/public/images/get_started128.png"
  },
  "permissions": [
  ]
}

标签: reactjsgoogle-chrome-extension

解决方案


不确定自从有人回答以来您是否已经弄清楚了这一点,但是一旦您完成了,就去做npm run build。这应该创建您的“构建”,它将包含您的清单文件,然后加载未打包的“构建”文件夹。

希望这可以帮助。


推荐阅读