gatsby: Error: Cannot find module 'gatsby-cli/lib/reporter'
Description
When trying to do gatsby build
, I’m noticing that my custom source plugins as well as Gatsby packages are trying to find gatsby-cli/lib/reporter
, so every build fails with something that looks like this:
error Error in "/Users/jaredsilver/projects/marketing-app/node_modules/gatsby-plugin-sharp/gatsby-node.js":
Error: Cannot find module 'gatsby-cli/lib/reporter'
Require stack:
- /Users/jaredsilver/projects/marketing-app/node_modules/gatsby-plugin-sharp/utils.js
- /Users/jaredsilver/projects/marketing-app/node_modules/gatsby-plugin-sharp/scheduler.js
- /Users/jaredsilver/projects/marketing-app/node_modules/gatsby-plugin-sharp/index.js
- /Users/jaredsilver/projects/marketing-app/node_modules/gatsby-plugin-sharp/gatsby-node.js
- /Users/jaredsilver/projects/marketing-app/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js
- /Users/jaredsilver/projects/marketing-app/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
- /Users/jaredsilver/projects/marketing-app/node_modules/gatsby/dist/bootstrap/load-plugins/load.js
- /Users/jaredsilver/projects/marketing-app/node_modules/gatsby/dist/bootstrap/load-plugins/index.js
- /Users/jaredsilver/projects/marketing-app/node_modules/gatsby/dist/bootstrap/index.js
- /Users/jaredsilver/projects/marketing-app/node_modules/gatsby/dist/commands/build.js
- /Users/jaredsilver/.nvm/versions/node/v12.2.0/lib/node_modules/gatsby-cli/lib/create-cli.js
- /Users/jaredsilver/.nvm/versions/node/v12.2.0/lib/node_modules/gatsby-cli/lib/index.js
Environment
I’ve tried a few different versions of gatsby, gatsby-cli, and where gatsby-cli lives, but this is one example:
System:
OS: macOS High Sierra 10.13.3
CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.2.0 - ~/.nvm/versions/node/v12.2.0/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v12.2.0/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 74.0.3729.169
Firefox: 59.0.2
Safari: 11.0.3
npmPackages:
gatsby: ^2.9.4 => 2.9.6
gatsby-image: ^2.1.4 => 2.1.4
gatsby-plugin-emotion: ^4.0.6 => 4.0.7
gatsby-plugin-portal: ^1.0.7 => 1.0.7
gatsby-plugin-purgecss: ^4.0.0 => 4.0.0
gatsby-plugin-react-helmet: ^3.0.12 => 3.0.12
gatsby-plugin-react-svg: ^2.1.1 => 2.1.1
gatsby-plugin-sass: ^2.0.11 => 2.0.11
gatsby-plugin-sentry: ^1.0.1 => 1.0.1
gatsby-plugin-sharp: ^2.1.5 => 2.1.6
gatsby-source-apiserver: ^2.1.2 => 2.1.2
gatsby-source-filesystem: ^2.0.39 => 2.0.40
gatsby-source-graphql: ^2.0.19 => 2.0.19
gatsby-transformer-sharp: ^2.1.21 => 2.1.21
gatsby-transformer-yaml: ^2.1.12 => 2.1.12
npmGlobalPackages:
gatsby-cli: 2.6.9
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 50 (18 by maintainers)
we rolled back the change for now so the latest npm packages shouldn’t have this issue. We’ll reiterate on the reporter-npm fix and ship it somewhere this week.
Thanks for sticking with us and helping us debug this issue! ❤️ Sorry for the inconveniences it may have caused.
This is caused by https://github.com/gatsbyjs/gatsby/commit/967597c12fc5d227de4c1767bf82bc751f2fe0d0
gatsby-plugin-sharp
:src/utils.js
gatsby-source-filesystem
:src/utils.js
Because of
require(`gatsby-cli/lib/reporter`)
This error doesn’t occur for
yarn
becauseyarn
flattens thenode_modules
tree. So,gatsby-cli
is available at./node_modules/gatsby-cli
. Withnpm
it’s./node_modules/gatsby/node_modules/gatsby-cli
.It works after
npm install gatsby-cli --save-dev
because, it addsgatsby-cli
at top level:./node_modules/gatsby-cli
@wardpeet @DanielRuf
As an immediate workaround you can use
yarn
instead ofnpm
rm -rf node_modules
yarn
gatsby develop
Seeing this issue too. As others have mentioned I’m able to get round this for the moment by installing the latest gatsby-cli package locally (2.6.9)
npm install --save-dev gatsby-cli
Oh my, I’ll have a look.
If i npm install gatsby-cli locally i get into another issue :
When I install gatsby-cli locally (npm install --save gatsby-cli), and run gatsby develop, I encounter this error:
`Error Warning: Can’t perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your
error UNHANDLED REJECTION
TypeError: Cannot read property ‘type’ of undefined
reporter.js:78 Object.done [mcmc2]/[gatsby]/[gatsby-cli]/lib/reporter/reporters/ink/reporter.js :78:54
index.js:132 Object.end [mcmc2]/[gatsby]/[gatsby-cli]/lib/reporter/index.js:132:18
index.js:134 [mcmc2]/[gatsby]/dist/bootstrap/index.js:134:14
Generator.next`
we just published a new version, i’ll be bumping our starters in a few minutes.
@zappys - I’m getting same error after running
npm install gatsby-cli --save-dev
The output is:
error Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous
error UNHANDLED REJECTION
TypeError: Cannot read property 'startTime' of undefined
Following @wardpeet 's instructions and installing the necessary @reporter-npm packages works.
For me, it was the following: npm install gatsby-plugin-sharp@reporter-npm npm install gatsby-source-filesystem@reporter-npm
Thank you!
@MitchellCash I’ve been using your reproduction to test this.
To Reproduce
(I’m using Node 11 and NPM 6.7.0; may matter)
git clone git@github.com:MitchellCash/MitchellCash.com.git
cd MitchellCash.com
git fetch origin dependabot/npm_and_yarn/gatsby-source-filesystem-2.0.40 && git checkout dependabot/npm_and_yarn/gatsby-source-filesystem-2.0.40
npm install
npm run build
Info
What I’m seeing currently:
ls node_modules | grep gatsby-cli
returns nothing)I’d imagine other people can confirm this as well. While I investigate further, this should be able to be fixed now with a temporary band-aid:
This will ensure the dependency makes its way into your node_modules tree. This shouldn’t be necessary, so please treat this as temporary.
Because it probably uses the lockfile which uses an older release.
UPDATE: NPM appears to be working now, don’t forget to install ALL the packages you need (he said to himself…), thanks @wardpeet !
npm install gatsby-plugin-sharp@reporter-npm
npm install gatsby-source-contentful@@reporter-npm
npm install gatsby-source-drupal@reporter-npm
npm install gatsby-source-filesystem@reporter-npm
npm install gatsby-source-shopify@reporter-npm
npm install gatsby-source-wordpress@reporter-npm
npm install gatsby-transformer-screenshot@reporter-npm
npm install gatsby-transformer-sqip@reporter-npm
@doodybrains that seems something else, could you create another issue for this.
I think I fixed the issue with NPM. I would love if people can test it out for me. I’ve updated a lot of packages so please install the correct packages. For example if you have
gatsby-source-wordpress
installed, please installgatsby-source-wordpress@reporter-npm
I published some versions to test, please install the ones that are in your package.json
npm install gatsby-plugin-sharp@reporter-npm
npm install gatsby-source-contentful@@reporter-npm
npm install gatsby-source-drupal@reporter-npm
npm install gatsby-source-filesystem@reporter-npm
npm install gatsby-source-shopify@reporter-npm
npm install gatsby-source-wordpress@reporter-npm
npm install gatsby-transformer-screenshot@reporter-npm
npm install gatsby-transformer-sqip@reporter-npm
@MunifTanjim he is aware of it, see https://github.com/gatsbyjs/gatsby/issues/14875#issuecomment-503203439
@KyleAMathews same issue still.
Ran:
rm -fr package-lock.json node_modules/
npm install
npm run develop
Error: Cannot find module 'gatsby-cli/lib/reporter'
Strange. The main project I’m working on is unaffected… but, if I try a fresh default project or “wordpress-tutorial-site”, I can’t even “gatsby develop” those. I had just ran “npm i gatsby-cli” not too long ago.
@narration-sd it’s getting a bit late for me, I’ll try to get to it this week.
@jkaracozoff that seems a different bug, any reproduction you can create for me? Feel free to send me a private email ward@gatsbyjs.com
@wardpeet sorry. i removed
gatsby-transformer-sharp
and now everything works…Negative
If y’all delete your lock files and reinstall, does that help?