Skip to content

[gatsby-plugin-manifest] Automatic mode error: Cannot read property '0' of undefined #4865

@alampros

Description

@alampros

Description

When running the plugin with no icons property in the options (only icon for the source image), gatsby build throws a build error.

Error: Cannot read property '0' of undefined

  - render-page.js:22888 Object.exports.onRenderBody
    render-page.js:22888:24

Steps to reproduce

  1. Configure gatsby-plugin-manifest as described in Automatic Mode
  2. Run gatsby build

Expected result

The plugin should use the defaultIcons from:

const defaultIcons = [
{
"src": `icons/icon-48x48.png`,
"sizes": `48x48`,
"type": `image/png`,
},
{
"src": `icons/icon-72x72.png`,
"sizes": `72x72`,
"type": `image/png`,
},
{
"src": `icons/icon-96x96.png`,
"sizes": `96x96`,
"type": `image/png`,
},
{
"src": `icons/icon-144x144.png`,
"sizes": `144x144`,
"type": `image/png`,
},
{
"src": `icons/icon-192x192.png`,
"sizes": `192x192`,
"type": `image/png`,
},
{
"src": `icons/icon-256x256.png`,
"sizes": `256x256`,
"type": `image/png`,
},
{
"src": `icons/icon-384x384.png`,
"sizes": `384x384`,
"type": `image/png`,
},
{
"src": `icons/icon-512x512.png`,
"sizes": `512x512`,
"type": `image/png`,
},
]

...and

  1. generate the default set of images
  2. populate the icons property of the manifest.json with the default icons

Actual result

Build throws error:

Error: Cannot read property '0' of undefined

  - render-page.js:22888 Object.exports.onRenderBody
    render-page.js:22888:24

Environment

  • Gatsby version (npm list gatsby): 1.9.246
  • gatsby-cli version (gatsby --version): 1.9.246
  • Node.js version: v8.11.0
  • Operating System: macOS 10.13.4

File contents (if changed):

gatsby-config.js:

    {
      resolve: 'gatsby-plugin-manifest',
      options: {
        name: pkg.title,
        short_name: pkg.shortName,
        start_url: '/',
        background_color: '#DFE7F7',
        theme_color: '#00A3DB',
        display: 'minimal-ui',
        icon: 'src/icon.png',
      },
    },
    'gatsby-plugin-offline',

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions