Gatsby: No longer able to find local plugin after upgrading Gatsby

Created on 28 Feb 2018  ·  7Comments  ·  Source: gatsbyjs/gatsby

Description

After upgrading to Gatsby 1.9.217 and changing no source code, develop and build now fail to find a locally-defined plugin. I've tried two different repos, each with a different local source plugin. The plugin folder is in a plugins folder at the project root and contains a gatsby-node.js and a package.json, the latter with just an empty object as its contents.

Environment

Gatsby version: 1.9.217
Node.js version: 9.2.0
Operating System: MacOS Sierra 10.12.6

File contents (if changed):

No changes.

Actual result

$ gatsby develop
success delete html and css files from previous builds — 0.068 s
success open and validate gatsby-config.js — 0.006 s
error UNHANDLED REJECTION


  Error: Unable to find plugin "gatsby-source-randomuser"

  - load.js:89 resolvePlugin
    [gatsby-source-api-test]/[gatsby]/dist/bootstrap/load-plugins/load.js:89:11

  - load.js:138 processPlugin
    [gatsby-source-api-test]/[gatsby]/dist/bootstrap/load-plugins/load.js:138:27

  - load.js:159
    [gatsby-source-api-test]/[gatsby]/dist/bootstrap/load-plugins/load.js:159:28

  - Array.forEach

  - load.js:158 _callee$
    [gatsby-source-api-test]/[gatsby]/dist/bootstrap/load-plugins/load.js:158:28

  - index.js:61 _callee$
    [gatsby-source-api-test]/[gatsby]/dist/bootstrap/load-plugins/index.js:61:18


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behavior

The local plugin should be found and used.

Steps to reproduce

1. Create a local plugin as outlined in the documentation

2. Add it to your gatsby-config.js

3. Try to develop or build

Most helpful comment

@KyleAMathews yep, #4275 should fix this :)

All 7 comments

Probably related to @m-allanson's PR https://github.com/gatsbyjs/gatsby/pull/3889

@KyleAMathews yep, #4275 should fix this :)

Thanks @tsriram! We really need integration tests :-(

🤦‍♂️

Thanks @tsriram! I'm looking forwards to when we have integration tests up and running.

Using "gatsby": "^2.0.105" and I'm definitely still seeing this bug:

  - load.js:107 resolvePlugin
    [gatsby]/dist/bootstrap/load-plugins/load.js:107:11

  - load.js:119 processPlugin
    [gatsby]/dist/bootstrap/load-plugins/load.js:119:20

  - load.js:169 config.plugins.forEach.plugin
    [gatsby]/dist/bootstrap/load-plugins/load.js:169:20

  - Array.forEach

  - load.js:168 module.exports
    [gatsby]/dist/bootstrap/load-plugins/load.js:168:20

  - index.js:56 
    [gatsby]/dist/bootstrap/load-plugins/index.js:56:21

  - Generator.next

  - new Promise

  - index.js:85 
    [gatsby]/dist/bootstrap/load-plugins/index.js:85:17

  - index.js:124 
    [gatsby]/dist/bootstrap/index.js:124:36

  - Generator.next

Tried both local plugin walkthroughs:
https://www.gatsbyjs.org/docs/creating-a-local-plugin/
https://github.com/gatsbyjs/gatsby/tree/master/examples/using-local-plugins

I'd faced a similar issue recently with a local plugin. Code that had been working fine for months started to fail with the following error.

Couldn't find the "<plugin-name>" plugin declared in "<path-to-project>/gatsby-config.js".

Tried looking for a local plugin in <path-to-project>/plugins/<plugin-name>.

Because I hadn't provided a value for main in my package.json file, gatsby was defaulting to index.js, which wasn't present. The solution is to either create an index.js file inside your plugin folder, or add the entry main: "gatsby-node.js" inside package.json

Thank you @PawanHegde ! There's no way I would have figured that out on my own after the error started surfacing when upgrading from 2.16.1 to 2.17.7.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandonmp picture brandonmp  ·  3Comments

kalinchernev picture kalinchernev  ·  3Comments

ghost picture ghost  ·  3Comments

mikestopcontinues picture mikestopcontinues  ·  3Comments

signalwerk picture signalwerk  ·  3Comments