Gatsby: Local plugin no longer resolvable [v2.17.7]

Created on 30 Oct 2019  ·  7Comments  ·  Source: gatsbyjs/gatsby

Description

After upgrading to gatsby v2.17.7 local plugins no longer work. Reverting to v2.17.6 resolves the issue.

Steps to reproduce

❯ yarn build
yarn run v1.19.1
$ gatsby build

 ERROR #10226  CONFIG

Couldn't find the "gatsby-plugin-capture-query-string" plugin declared in "/Users/user/work/project/landing/gatsby-config.js".

Tried looking for a local plugin in /Users/user/work/project/landing/plugins/gatsby-plugin-capture-query-string.

Tried looking for an installed package in the following paths:
 - /Users/user/work/project/landing/node_modules/gatsby/dist/bootstrap/load-themes/node_modules/gatsby-plugin-capture-query-string
 - /Users/user/work/project/landing/node_modules/gatsby/dist/bootstrap/node_modules/gatsby-plugin-capture-query-string
 - /Users/user/work/project/landing/node_modules/gatsby/dist/node_modules/gatsby-plugin-capture-query-string
 - /Users/user/work/project/landing/node_modules/gatsby/node_modules/gatsby-plugin-capture-query-string
 - /Users/user/work/project/landing/node_modules/gatsby-plugin-capture-query-string
 - /Users/user/work/project/node_modules/gatsby-plugin-capture-query-string
 - /Users/user/work/node_modules/gatsby-plugin-capture-query-string
 - /Users/user/node_modules/gatsby-plugin-capture-query-string
 - /Users/node_modules/gatsby-plugin-capture-query-string
 - /node_modules/gatsby-plugin-capture-query-string

not finished open and validate gatsby-configs - 0.057s
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

```
❯ ls -la /Users/user/work/project/landing/plugins/gatsby-plugin-capture-query-string
total 16
drwxr-xr-x 4 user staff 128 Aug 7 09:26 .
drwxr-xr-x 3 user staff 96 Aug 7 09:26 ..
-rw-r--r-- 1 user staff 164 Aug 7 09:26 gatsby-browser.js
-rw-r--r-- 1 user staff 3 Oct 30 12:11 package.json


package.json
```json
{}

gatsby-browser.js

import { captureQueryString } from 'capture-query-string';

export const onRouteUpdate = ({ location }, pluginOptions = {}) => {
  captureQueryString(location);
};

Expected result

v2.17.7 is a semver patch and should not exhibit any change in behavior. Local plugins should still work.

Actual result

Local plugins no longer work

Environment

❯ ./node_modules/.bin/gatsby info --clipboard

  System:
    OS: macOS 10.15.1
    CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node
    Yarn: 1.19.1 - ~/.nvm/versions/node/v12.13.0/bin/yarn
    npm: 6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm
  Languages:
    Python: 2.7.17 - /usr/local/bin/python
  Browsers:
    Chrome: 78.0.3904.70
    Firefox: 70.0
    Safari: 13.0.3
  npmPackages:
    gatsby: 2.17.7 => 2.17.7
    gatsby-background-image: 0.8.15 => 0.8.15
    gatsby-image: 2.2.30 => 2.2.30
    gatsby-plugin-manifest: 2.2.26 => 2.2.26
    gatsby-plugin-netlify: 2.1.23 => 2.1.23
    gatsby-plugin-react-helmet: 3.1.13 => 3.1.13
    gatsby-plugin-robots-txt: 1.5.0 => 1.5.0
    gatsby-plugin-sharp: 2.2.36 => 2.2.36
    gatsby-plugin-sitemap: 2.2.19 => 2.2.19
    gatsby-plugin-styled-components: 3.1.11 => 3.1.11
    gatsby-source-filesystem: 2.1.35 => 2.1.35
    gatsby-transformer-sharp: 2.3.2 => 2.3.2
good first issue help wanted documentation

Most helpful comment

I was able to get the build to proceed after adding an empty index.js // noop file to my plugin as per https://www.gatsbyjs.org/docs/files-gatsby-looks-for-in-a-plugin/. The documentation should be updated to state that this is now required as of [email protected]

All 7 comments

I believe it is caused by #15856

I was able to get the build to proceed after adding an empty index.js // noop file to my plugin as per https://www.gatsbyjs.org/docs/files-gatsby-looks-for-in-a-plugin/. The documentation should be updated to state that this is now required as of [email protected]

@esetnik - great find, thanks for this!

I was able to get the build to proceed after adding an empty index.js // noop file to my plugin as per https://www.gatsbyjs.org/docs/files-gatsby-looks-for-in-a-plugin/. The documentation should be updated to state that this is now required as of [email protected]

It should also be added to https://www.gatsbyjs.org/docs/creating-a-local-plugin/

It shouldn't say that it is required from 2.17.7 and onwards as it was always required (also by npm itself). The documentation should be updated, yes, but say that the index.js file is also required and link to https://www.gatsbyjs.org/docs/files-gatsby-looks-for-in-a-plugin/ for further details.

We'd highly appreciate a PR for that!

It wasn’t always required in the sense that it was working just fine without having an index.js file before the latest update.

dropping in the empty index.js worked for me

Fixed by @vladar and published in [email protected]

Thank you for reporting!

Was this page helpful?
0 / 5 - 0 ratings