netlify / netlify-plugin-gatsby

A build plugin to integrate Gatsby seamlessly with Netlify

Home Page:https://www.npmjs.com/package/@netlify/plugin-gatsby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Netlify deployment fails with message: "Cannot find module '@gatsbyjs/reach-router/lib/utils'"

nikoheikkila opened this issue · comments

Summary

After updating my site to Gatsby 5, I can no longer use this plugin in my configuration.

Steps to reproduce

  1. Install and use Gatsby 5.2.0
  2. Install the plugin through the Netlify plugins directory or activate it through the netlify.toml file
  3. Follow the provided setup instructions in the documentation

A link to a reproduction repository

No response

Plugin version

3.4.8

More information about your build

  • I am building using the CLI
  • I am building using file-based configuration (netlify.toml)

What OS are you using?

None

Your netlify.toml file

`netlify.toml`
[build]
  base = "/"
  command = "yarn build"
  publish = "public/"

[build.processing.css]
  bundle = true
  minify = false
[build.processing.js]
  bundle = true
  minify = false
[build.processing.html]
  pretty_urls = true
[build.processing.images]
  compress = true

[[plugins]]
package = "@netlify/plugin-gatsby"

[[headers]]
  for = "/rss.xml"
  [headers.values]
    Cache-Control = "no-cache"

[[redirects]]
  from = "/feed"
  to = "/rss.xml"
  status = 200
  force = true

Configuration

`gatsby-config.ts` and options
import type { GatsbyConfig } from "gatsby";
import { rssQuery, serialize } from "./src/utils/rss";

const environment = process.env.NODE_ENV;
const isProduction = environment === "production";

const config: GatsbyConfig = {
    siteMetadata: {
        language: `en`,
        title: `Blog | Niko Heikkilä`,
        author: {
            name: `Niko Heikkilä`,
        },
        description: `A blog by Niko Heikkilä. Powered by coffee, VS Code, and Gatsby.`,
        siteUrl: `https://nikoheikkila.fi`,
    },
    trailingSlash: "always",
    flags: {
        PRESERVE_FILE_DOWNLOAD_CACHE: true,
        FAST_DEV: true,
        DEV_SSR: false,
    },
    plugins: [
        `gatsby-plugin-image`,
        `gatsby-transformer-sharp`,
        `gatsby-plugin-sharp`,
        {
            resolve: `gatsby-transformer-remark`,
            options: {
                plugins: [
                    {
                        resolve: `gatsby-remark-images`,
                        options: {
                            maxWidth: 960,
                        },
                    },
                    {
                        resolve: `gatsby-remark-autolink-headers`,
                        options: {
                            icon: false,
                        },
                    },
                    `gatsby-remark-copy-linked-files`,
                    `gatsby-remark-smartypants`,
                ],
            },
        },
        {
            resolve: `gatsby-source-filesystem`,
            options: {
                path: "./content",
                name: `blog`,
            },
        },
        {
            resolve: `gatsby-source-filesystem`,
            options: {
                path: "./src/assets",
                name: `assets`,
            },
        },
        {
            resolve: `gatsby-plugin-feed`,
            options: {
                query: `{
                    site {
                        siteMetadata {
                            title
                            description
                            siteUrl
                            site_url: siteUrl
                        }
                    }
                }`,
                feeds: [
                    {
                        serialize,
                        query: rssQuery,
                        output: `/rss.xml`,
                        title: `RSS Feed | Niko Heikkilä`,
                        match: `^/blog/`,
                    },
                ],
            },
        },
        {
            resolve: `gatsby-plugin-manifest`,
            options: {
                name: `Niko Heikkilä`,
                short_name: `nikoheikkila`,
                start_url: `/`,
                background_color: `#ffffff`,
                theme_color: `#663399`,
                display: `standalone`,
                icon: `src/static/favicon.png`,
                crossOrigin: `use-credentials`,
            },
        },
        {
            resolve: `gatsby-plugin-robots-txt`,
            options: {
                policy: [{ userAgent: "*", allow: "/" }],
                output: `/robots.txt`,
            },
        },
        {
            resolve: `gatsby-plugin-typescript`,
            options: {
                isTSX: true,
                allExtensions: true,
            },
        },
        {
            resolve: `gatsby-plugin-sass`,
            options: {
                sassOptions: {
                    includePaths: ["./src/styles"],
                },
            },
        },
        `gatsby-plugin-sitemap`,
        `gatsby-plugin-netlify`,
    ].concat(
        // Load the PWA service worker only in production to enhance development experience.
        isProduction ? [`gatsby-plugin-offline`] : []
    ),
};

export default config;

Environment

Environment
  System:
    OS: macOS 12.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 2.92 GB / 64.00 GB
    Shell: 3.5.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 18.12.1 - ~/Library/Caches/fnm_multishells/12047_1670673446030/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.1.1 - ~/Library/Caches/fnm_multishells/12047_1670673446030/bin/npm
  Browsers:
    Chrome: 105.0.5195.102
    Safari: 16.1
  npmPackages:
    @netlify/plugin-gatsby: 3.4.8 => 3.4.8 

Gatsby info

gatsby info
  System:
    OS: macOS 12.6.1
    CPU: (10) arm64 Apple M1 Max
    Shell: 3.5.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 18.12.1 -
~/Library/Caches/fnm_multishells/12047_1670673446030/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.1.1 - ~/Library/Caches/fnm_multishells/12047_1670673446030/bin/npm
  Languages:
    Python: 3.11.0 - /Users/niko.heikkila/.pyenv/shims/python
  Browsers:
    Chrome: 105.0.5195.102
    Safari: 16.1
  npmPackages:
    gatsby: 5.2.0 => 5.2.0
    gatsby-plugin-feed: 5.2.0 => 5.2.0
    gatsby-plugin-image: 3.2.0 => 3.2.0
    gatsby-plugin-manifest: 5.2.0 => 5.2.0
    gatsby-plugin-netlify: 5.1.0 => 5.1.0
    gatsby-plugin-offline: 6.2.0 => 6.2.0
    gatsby-plugin-robots-txt: 1.8.0 => 1.8.0
    gatsby-plugin-sass: 6.2.0 => 6.2.0
    gatsby-plugin-sharp: 5.2.0 => 5.2.0
    gatsby-plugin-sitemap: 6.2.0 => 6.2.0
    gatsby-plugin-typescript: 5.2.0 => 5.2.0
    gatsby-remark-autolink-headers: 6.2.0 => 6.2.0
    gatsby-remark-copy-linked-files: 6.2.0 => 6.2.0    gatsby-remark-images: 7.2.0 => 7.2.0
    gatsby-remark-smartypants: 6.2.0 => 6.2.0
    gatsby-source-filesystem: 5.2.0 => 5.2.0
    gatsby-transformer-remark: 6.2.0 => 6.2.0
    gatsby-transformer-sharp: 5.2.0 => 5.2.0

Your _redirects file

`_redirects`
/* /404.html 404

Builds logs (or link to your logs)

Build logs

See here

Function logs

Function logs
# Paste logs here

@nikoheikkila, we have some work going in soon to support Gatsby v5. See #547. It might not be related to the missing module, but give it a go after #547 gets released.

@nikoheikkila, we have some work going in soon to support Gatsby v5. See #547. It might not be related to the missing module, but give it a go after #547 gets released.

Thanks! I can confirm that plugin version 3.5.0 works with Gatsby 5. 👍🏼

@nikoheikkila, we have some work going in soon to support Gatsby v5. See #547. It might not be related to the missing module, but give it a go after #547 gets released.

Thanks! I can confirm that plugin version 3.5.0 works with Gatsby 5. 👍🏼

Hi, how did you make it working ?

Netlify keep using 3.4.8 version... I tried UI install & .toml file

4:53:21 PM: ❯ Loading plugins
4:53:21 PM: - @netlify/plugin-gatsby@3.4.8 from netlify.toml
4:53:23 PM: ​
4:53:23 PM: Plugin "@netlify/plugin-gatsby" internal error