首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gatsby - "value“必须至少包含[图标,图标]中的一个。

Gatsby - "value“必须至少包含[图标,图标]中的一个。
EN

Stack Overflow用户
提问于 2021-01-11 09:33:52
回答 2查看 2.4K关注 0票数 4

当我在控制台中运行gatsby开发时,会出现以下错误:

错误#11331插件无效插件选项“gatsby- PLUGIN -清单”:-“值”必须至少包含一个图标,图标。

我刚刚克隆了一个初学者github分支这里并安装了所有节点模块。记住,我是新来的反应/盖茨比。我在网上搜索这个错误,但没有找到任何有用的信息。

这是我的gatsby-config.js:

代码语言:javascript
复制
module.exports = {
  siteMetadata: {
    title: `Gatsby Default Starter`,
    description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
    author: `@gatsbyjs`,
  },
  plugins: [
    `gatsby-plugin-feed`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `Gatsby Starter Blog`,
        short_name: `GatsbyJS`,
        start_url: `/`,
        background_color: `#ffffff`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `${__dirname}/src/assets`,
      },
    },  
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `assets`,
        path: `${__dirname}/src/assets`,
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
      },
    },
    `gatsby-plugin-styled-components`,
    // this (optional) plugin enables Progressive Web App + Offline functionality
    // To learn more, visit: https://gatsby.dev/offline
    // `gatsby-plugin-offline`,
  ],
}

这是我的package.json:

代码语言:javascript
复制
{
  "name": "gatsby-starter-default",
  "private": true,
  "description": "A simple starter to get up and developing quickly with Gatsby",
  "version": "0.1.0",
  "author": "Kyle Mathews <mathews.kyle@gmail.com>",
  "dependencies": {
    "babel-plugin-styled-components": "^1.10.7",
    "framer-motion": "^1.10.2",
    "gatsby": "^2.19.45",
    "gatsby-image": "^2.2.44",
    "gatsby-plugin-feed": "^2.11.0",
    "gatsby-plugin-manifest": "^2.10.0",
    "gatsby-plugin-offline": "^3.0.41",
    "gatsby-plugin-react-helmet": "^3.1.24",
    "gatsby-plugin-sharp": "^2.4.13",
    "gatsby-plugin-styled-components": "^3.2.1",
    "gatsby-source-filesystem": "^2.1.56",
    "gatsby-transformer-sharp": "^2.3.19",
    "prop-types": "^15.7.2",
    "react": "^16.12.0",
    "react-canvas": "^1.3.0",
    "react-dom": "^16.12.0",
    "react-helmet": "^5.2.1",
    "react-intersection-observer": "^8.26.1",
    "styled-components": "^5.0.1",
    "styled-normalize": "^8.0.7"
  },
  "devDependencies": {
    "prettier": "^1.19.1"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{js,jsx,json,md}\"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gatsbyjs/gatsby-starter-default"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  }
}

(如有任何协助,请见习!)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-01-11 09:59:47

在您的gatsby-plufin manifest中有两个gatsby-config.js实例。删除其中一项:

代码语言:javascript
复制
module.exports = {
  siteMetadata: {
    title: `Gatsby Default Starter`,
    description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
    author: `@gatsbyjs`,
  },
  plugins: [
    `gatsby-plugin-feed`,  
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `assets`,
        path: `${__dirname}/src/assets`,
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
      },
    },
    `gatsby-plugin-styled-components`,
    // this (optional) plugin enables Progressive Web App + Offline functionality
    // To learn more, visit: https://gatsby.dev/offline
    // `gatsby-plugin-offline`,
  ],
}

如果您不想使用图标,因为它不是强制属性,您可以删除它。但是,如果使用它,则必须提供有效的图标,而不是文件夹:

代码语言:javascript
复制
icon: `${__dirname}/src/assets/iconName.png`,
票数 1
EN

Stack Overflow用户

发布于 2021-01-11 10:04:43

代码语言:javascript
复制
  icon: `${__dirname}/src/assets`,

上面的行必须指向文件,而不是文件夹。

https://www.gatsbyjs.com/plugins/gatsby-plugin-manifest/#hybrid-mode-configuration

代码语言:javascript
复制
 module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `GatsbyJS`,
        short_name: `GatsbyJS`,
        start_url: `/`,
        background_color: `#f7f0eb`,
        theme_color: `#a2466c`,
        display: `standalone`,
 icon: `src/images/icon.png`, // This path is relative to the root of the site.
      icons: [
        {
          src: `/favicons/android-chrome-192x192.png`,
          sizes: `192x192`,
          type: `image/png`,
        },
        {
          src: `/favicons/android-chrome-512x512.png`,
          sizes: `512x512`,
          type: `image/png`,
        },
      ], // Add or remove icon sizes as desired
      },
    },
  ],
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65664292

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档