gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.27k stars 10.31k forks source link

gatsby-remark-copy-linked-files causes errors when upgrading from v3 to v4 #33652

Closed barbalex closed 3 years ago

barbalex commented 3 years ago

Preliminary Checks

Description

I am upgrading from v3 to v4.

My gatsby-config.js contains gatsby-remark-copy-linked-files:

module.exports = {
  siteMetadata: {
    title: 'arteigenschaften',
  },
  plugins: [
    {
      resolve: 'gatsby-plugin-create-client-paths',
      options: {
        prefixes: [
          `/Arten/*`,
          `/Lebensräume/*`,
          `/Eigenschaften-Sammlungen/*`,
          `/Export/*`,
          `/artenlistentool/*`,
          `/Benutzer/*`,
          `/Organisationen/*`,
        ],
      },
    },
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/docs`,
        name: 'docs-pages',
      },
    },
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        name: 'images',
        path: `${__dirname}/src/images`,
      },
    },
    `gatsby-plugin-image`,
    'gatsby-plugin-sharp',
    'gatsby-transformer-sharp',
    {
      resolve: 'gatsby-plugin-typography',
      options: {
        pathToConfigModule: './src/modules/typography.js',
        omitGoogleFont: true,
      },
    },
    'gatsby-plugin-react-helmet',
    'gatsby-plugin-styled-components',
    {
      resolve: 'gatsby-plugin-manifest',
      options: {
        // uncommented scope because of gatsby issue
        // https://github.com/gatsbyjs/gatsby/issues/27839
        scope: '.',
        name: 'arteigenschaften.ch',
        short_name: 'arteigenschaften',
        start_url: './',
        background_color: '#e65100',
        theme_color: '#e65100',
        display: 'minimal-ui',
        icon: 'src/images/favicon256.png',
        include_favicon: true,
        description:
          'Eigenschaften von Flora, Fauna, Moosen und Lebensräumen: Sichten, exportieren, importieren',
      },
    },
    {
      resolve: 'gatsby-transformer-remark',
      options: {
        gfm: true,
        commonmark: true,
        footnotes: true,
        pedantic: true,
        excerpt_separator: '<!-- end -->',
        plugins: [
          {
            resolve: 'gatsby-remark-images',
            options: {
              maxWidth: 2000,
              // uncomment this again when gatsby-plugin-manifest > 2.5.2
              //wrapperStyle: 'margin-left: 0;',
              linkImagesToOriginal: false,
            },
          },
          {
            resolve: 'gatsby-remark-autolink-headers',
            options: {
              offsetY: '64',
            },
          },
          {
            resolve: 'gatsby-remark-emojis',
            options: {
              // Deactivate the plugin globally (default: true)
              active: true,
              // Add a custom css class
              class: 'emoji-icon',
              // Select the size (available size: 16, 24, 32, 64)
              size: 32,
              // Add custom styles
              styles: {
                display: 'inline',
                margin: '0',
                'margin-top': '-3px',
                position: 'relative',
                top: '3px',
                width: '20px',
              },
            },
          },
          {
            resolve: 'gatsby-remark-external-links',
            options: {
              target: '_self',
              rel: 'nofollow',
            },
          },
          {
            resolve: `gatsby-remark-images-medium-zoom`, // point!
            options: {
              background: 'rgba(128,128,128,0.5)',
            },
          },
          'gatsby-remark-copy-linked-files',
        ],
      },
    },
    'gatsby-plugin-offline',
  ],
}

When I run yarn dev after upgrading, this happens:

$ gatsby develop
warn Warning: there are unknown plugin options for "gatsby-transformer-remark": commonmark, pedantic
Please open an issue at ghub.io/gatsby-transformer-remark if you believe this option is valid.
success open and validate gatsby-configs, load plugins - 0.955s
success onPreInit - 0.006s                                                                                                                                                                                                                            
success initialize cache - 0.040s
success copy gatsby files - 0.148s
success Compiling Gatsby Functions - 0.308s
success onPreBootstrap - 0.327s

 ERROR #11321  PLUGIN

"gatsby-transformer-remark" threw an error while running the createSchemaCustomization lifecycle:

Cannot read properties of undefined (reading 'createSchemaCustomization')

  TypeError: Cannot read properties of undefined (reading 'createSchemaCustomization')

  - create-schema-customization.js:47
    [ae2]/[gatsby-transformer-remark]/create-schema-customization.js:47:31

  - Array.forEach

  - create-schema-customization.js:44 Object.module.exports [as createSchemaCustomization]
    [ae2]/[gatsby-transformer-remark]/create-schema-customization.js:44:11

  - api-runner-node.js:430 runAPI
    [ae2]/[gatsby]/src/utils/api-runner-node.js:430:22

  - api-runner-node.js:581 Promise.catch.decorateEvent.pluginName
    [ae2]/[gatsby]/src/utils/api-runner-node.js:581:13

  - debuggability.js:384 Promise._execute
    [ae2]/[bluebird]/js/release/debuggability.js:384:9

  - promise.js:518 Promise._resolveFromExecutor
    [ae2]/[bluebird]/js/release/promise.js:518:18

  - promise.js:103 new Promise
    [ae2]/[bluebird]/js/release/promise.js:103:10

  - api-runner-node.js:579
    [ae2]/[gatsby]/src/utils/api-runner-node.js:579:16

  - util.js:16 tryCatcher
    [ae2]/[bluebird]/js/release/util.js:16:23

  - reduce.js:166 Object.gotValue
    [ae2]/[bluebird]/js/release/reduce.js:166:18

  - reduce.js:155 Object.gotAccum
    [ae2]/[bluebird]/js/release/reduce.js:155:25

  - util.js:16 Object.tryCatcher
    [ae2]/[bluebird]/js/release/util.js:16:23

  - promise.js:547 Promise._settlePromiseFromHandler
    [ae2]/[bluebird]/js/release/promise.js:547:31

  - promise.js:604 Promise._settlePromise
    [ae2]/[bluebird]/js/release/promise.js:604:18

  - promise.js:649 Promise._settlePromise0
    [ae2]/[bluebird]/js/release/promise.js:649:10

success createSchemaCustomization - 0.113s                                                                                                                                                                                                            
success Checking for changed pages - 0.002s                                                                                                                                                                                                           
success source and transform nodes - 0.193s                                                                                                                                                                                                           

 ERROR #11321  PLUGIN

"gatsby-transformer-remark" threw an error while running the setFieldsOnGraphQLNodeType lifecycle:

Cannot read properties of undefined (reading 'setParserPlugins')

  TypeError: Cannot read properties of undefined (reading 'setParserPlugins')

  - extend-node-type.js:146
    [ae2]/[gatsby-transformer-remark]/extend-node-type.js:146:39

  - new Promise

  - extend-node-type.js:111 Object.remarkExtendNodeType [as setFieldsOnGraphQLNodeType]
    [ae2]/[gatsby-transformer-remark]/extend-node-type.js:111:10

  - api-runner-node.js:430 runAPI
    [ae2]/[gatsby]/src/utils/api-runner-node.js:430:22

  - api-runner-node.js:581 Promise.catch.decorateEvent.pluginName
    [ae2]/[gatsby]/src/utils/api-runner-node.js:581:13

  - debuggability.js:384 Promise._execute
    [ae2]/[bluebird]/js/release/debuggability.js:384:9

  - promise.js:518 Promise._resolveFromExecutor
    [ae2]/[bluebird]/js/release/promise.js:518:18

  - promise.js:103 new Promise
    [ae2]/[bluebird]/js/release/promise.js:103:10

  - api-runner-node.js:579
    [ae2]/[gatsby]/src/utils/api-runner-node.js:579:16

  - util.js:16 tryCatcher
    [ae2]/[bluebird]/js/release/util.js:16:23

  - reduce.js:166 Object.gotValue
    [ae2]/[bluebird]/js/release/reduce.js:166:18

  - reduce.js:155 Object.gotAccum
    [ae2]/[bluebird]/js/release/reduce.js:155:25

  - util.js:16 Object.tryCatcher
    [ae2]/[bluebird]/js/release/util.js:16:23

  - promise.js:547 Promise._settlePromiseFromHandler
    [ae2]/[bluebird]/js/release/promise.js:547:31

  - promise.js:604 Promise._settlePromise
    [ae2]/[bluebird]/js/release/promise.js:604:18

  - promise.js:649 Promise._settlePromise0
    [ae2]/[bluebird]/js/release/promise.js:649:10

 ERROR #11321  PLUGIN

"gatsby-transformer-remark" threw an error while running the setFieldsOnGraphQLNodeType lifecycle:

Cannot read properties of undefined (reading 'setParserPlugins')

  TypeError: Cannot read properties of undefined (reading 'setParserPlugins')

  - extend-node-type.js:146
    [ae2]/[gatsby-transformer-remark]/extend-node-type.js:146:39

  - new Promise

  - extend-node-type.js:111 Object.remarkExtendNodeType [as setFieldsOnGraphQLNodeType]
    [ae2]/[gatsby-transformer-remark]/extend-node-type.js:111:10

  - api-runner-node.js:430 runAPI
    [ae2]/[gatsby]/src/utils/api-runner-node.js:430:22

  - api-runner-node.js:581 Promise.catch.decorateEvent.pluginName
    [ae2]/[gatsby]/src/utils/api-runner-node.js:581:13

  - debuggability.js:384 Promise._execute
    [ae2]/[bluebird]/js/release/debuggability.js:384:9

  - promise.js:518 Promise._resolveFromExecutor
    [ae2]/[bluebird]/js/release/promise.js:518:18

  - promise.js:103 new Promise
    [ae2]/[bluebird]/js/release/promise.js:103:10

  - api-runner-node.js:579
    [ae2]/[gatsby]/src/utils/api-runner-node.js:579:16

  - util.js:16 tryCatcher
    [ae2]/[bluebird]/js/release/util.js:16:23

  - reduce.js:166 Object.gotValue
    [ae2]/[bluebird]/js/release/reduce.js:166:18

  - reduce.js:155 Object.gotAccum
    [ae2]/[bluebird]/js/release/reduce.js:155:25

  - util.js:16 Object.tryCatcher
    [ae2]/[bluebird]/js/release/util.js:16:23

  - promise.js:547 Promise._settlePromiseFromHandler
    [ae2]/[bluebird]/js/release/promise.js:547:31

  - promise.js:604 Promise._settlePromise
    [ae2]/[bluebird]/js/release/promise.js:604:18

  - promise.js:649 Promise._settlePromise0
    [ae2]/[bluebird]/js/release/promise.js:649:10

 ERROR #11321  PLUGIN

"gatsby-transformer-remark" threw an error while running the setFieldsOnGraphQLNodeType lifecycle:

Cannot read properties of undefined (reading 'setParserPlugins')

  TypeError: Cannot read properties of undefined (reading 'setParserPlugins')

  - extend-node-type.js:146
    [ae2]/[gatsby-transformer-remark]/extend-node-type.js:146:39

  - new Promise

  - extend-node-type.js:111 Object.remarkExtendNodeType [as setFieldsOnGraphQLNodeType]
    [ae2]/[gatsby-transformer-remark]/extend-node-type.js:111:10

  - api-runner-node.js:430 runAPI
    [ae2]/[gatsby]/src/utils/api-runner-node.js:430:22

  - api-runner-node.js:581 Promise.catch.decorateEvent.pluginName
    [ae2]/[gatsby]/src/utils/api-runner-node.js:581:13

  - debuggability.js:384 Promise._execute
    [ae2]/[bluebird]/js/release/debuggability.js:384:9

  - promise.js:518 Promise._resolveFromExecutor
    [ae2]/[bluebird]/js/release/promise.js:518:18

  - promise.js:103 new Promise
    [ae2]/[bluebird]/js/release/promise.js:103:10

  - api-runner-node.js:579
    [ae2]/[gatsby]/src/utils/api-runner-node.js:579:16

  - util.js:16 tryCatcher
    [ae2]/[bluebird]/js/release/util.js:16:23

  - reduce.js:166 Object.gotValue
    [ae2]/[bluebird]/js/release/reduce.js:166:18

  - reduce.js:155 Object.gotAccum
    [ae2]/[bluebird]/js/release/reduce.js:155:25

  - util.js:16 Object.tryCatcher
    [ae2]/[bluebird]/js/release/util.js:16:23

  - promise.js:547 Promise._settlePromiseFromHandler
    [ae2]/[bluebird]/js/release/promise.js:547:31

  - promise.js:604 Promise._settlePromise
    [ae2]/[bluebird]/js/release/promise.js:604:18

  - promise.js:649 Promise._settlePromise0
    [ae2]/[bluebird]/js/release/promise.js:649:10

success building schema - 0.697s
success createPages - 0.082s
success createPagesStatefully - 0.171s
info Total nodes: 144, SitePage nodes: 20 (use --verbose for breakdown)
success Checking for changed pages - 0.001s                                                                                                                                                                                                           
success write out redirect data - 0.002s
success Build manifest and related icons - 0.096s
success onPostBootstrap - 0.102s
info bootstrap finished - 4.948s
success onPreExtractQueries - 0.001s                                                                                                                                                                                                                  

 ERROR #85923  GRAPHQL

There was an error in your GraphQL query:

Cannot query field "html" on type "MarkdownRemark".

If you don't expect "html" to exist on the type "MarkdownRemark" it is most likely a typo.
However, if you expect "html" to exist there are a couple of solutions to common problems:

- If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
- The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
- You want to optionally use your field "html" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add at least one entry with that field ("dummy content")

It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "MarkdownRemark":
https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization#creating-type-definitions

File: src\templates\docTemplate.js:159:7

failed extract queries from components - 4.263s                                                                                                                                                                                                       
success write out requires - 0.023s
success run page queries - 0.008s - 1/1 119.85/s
⠀
You can now view artdaten in the browser.                                                                                                                                                                                                             
⠀                                                                                                                                                                                                                                                     
  http://localhost:8000/                                                                                                                                                                                                                              
⠀                                                                                                                                                                                                                                                     
View GraphiQL, an in-browser IDE, to explore your site's data and schema                                                                                                                                                                              
⠀                                                                                                                                                                                                                                                     
  http://localhost:8000/___graphql                                                                                                                                                                                                                    
⠀                                                                                                                                                                                                                                                     
Note that the development build is not optimized.                                                                                                                                                                                                     
To create a production build, use gatsby build                                                                                                                                                                                                        
⠀
success Building development bundle - 6.230s
success Writing page-data.json files to public directory - 0.262s - 3/20 76.21/s

When uncomment gatsby-remark-copy-linked-files everything works fine.

Reproduction Link

https://github.com/barbalex/ae2

Steps to Reproduce

  1. yarn
  2. yarn dev

Sorry, I don't know how to build the reproduction correctly so this is my repo.

Expected Result

The error should not happen.

Actual Result

See above, "what I am seeing".

Environment

System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
  Binaries:
    Node: 16.9.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.15 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 7.21.1 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 2.7.17 - C:\Python27\python.EXE
  Browsers:
    Chrome: 94.0.4606.81
    Edge: Spartan (44.22000.120.0), Chromium (95.0.1020.30)
  npmPackages:
    gatsby: 4.0.0 => 4.0.0
    gatsby-cli: 4.0.0 => 4.0.0
    gatsby-plugin-create-client-paths: 4.0.0 => 4.0.0
    gatsby-plugin-image: 2.0.0 => 2.0.0
    gatsby-plugin-manifest: 4.0.0 => 4.0.0
    gatsby-plugin-offline: 5.0.0 => 5.0.0
    gatsby-plugin-react-helmet: 5.0.0 => 5.0.0
    gatsby-plugin-sharp: 4.0.0 => 4.0.0
    gatsby-plugin-styled-components: 5.0.0 => 5.0.0
    gatsby-plugin-typography: 4.0.0 => 4.0.0
    gatsby-remark-autolink-headers: 5.0.0 => 5.0.0
    gatsby-remark-copy-linked-files: 5.0.0 => 5.0.0
    gatsby-remark-emojis: 0.4.3 => 0.4.3
    gatsby-remark-external-links: 0.0.4 => 0.0.4
    gatsby-remark-images: 6.0.0 => 6.0.0
    gatsby-remark-images-medium-zoom: 1.7.0 => 1.7.0
    gatsby-source-filesystem: 4.0.0 => 4.0.0
    gatsby-transformer-remark: 5.0.0 => 5.0.0
    gatsby-transformer-sharp: 4.0.0 => 4.0.0

Config Flags

No response

barbalex commented 3 years ago

Uups, seems that options have changed. Closing