gatsby: TypeError: Cannot read property 'activities' of undefined in yoga-layout-prebuilt

Description

gatsby build and gatsby develop both throw the error above.

Steps to reproduce

git checkout npm i ./node_modules/.bin/gatsby develop or ./node_modules/.bin/gatsby build https://github.com/ochronus/ochronus.online-gatsby

Expected result

Gatsby should build the site

Actual result

Gatsby threw an error

Environment

  System:
    OS: macOS 10.15.4
    CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
    Shell: 3.1.0 - /usr/local/bin/fish
  Binaries:
    Node: 13.13.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
  Languages:
    Python: 3.8.0 - /Users/ochronus/.pyenv/shims/python
  Browsers:
    Chrome: 81.0.4044.113
    Firefox: 75.0
    Safari: 13.1
  npmPackages:
    gatsby: ^2.19.49 => 2.19.49
    gatsby-cli: ^2.11.9 => 2.11.9
    gatsby-image: ^2.3.3 => 2.3.3
    gatsby-plugin-canonical-urls: ^2.2.2 => 2.2.2
    gatsby-plugin-draft: 0.0.5 => 0.0.5
    gatsby-plugin-feed: ^2.4.2 => 2.4.2
    gatsby-plugin-google-analytics: ^2.1.38 => 2.1.38
    gatsby-plugin-manifest: ^2.3.3 => 2.3.3
    gatsby-plugin-netlify: ^2.2.2 => 2.2.2
    gatsby-plugin-netlify-cache: ^1.2.0 => 1.2.0
    gatsby-plugin-offline: ^3.1.2 => 3.1.2
    gatsby-plugin-react-helmet: ^3.2.3 => 3.2.3
    gatsby-plugin-s3: ^0.3.3 => 0.3.3
    gatsby-plugin-sharp: ^2.5.3 => 2.5.3
    gatsby-plugin-sitemap: ^2.3.3 => 2.3.3
    gatsby-plugin-typography: ^2.4.2 => 2.4.2
    gatsby-remark-copy-linked-files: ^2.2.1 => 2.2.1
    gatsby-remark-images: ^3.2.1 => 3.2.1
    gatsby-remark-prismjs: ^3.3.36 => 3.3.36
    gatsby-remark-responsive-iframe: ^2.3.1 => 2.3.1
    gatsby-remark-smartypants: ^2.2.2 => 2.2.2
    gatsby-source-filesystem: ^2.2.2 => 2.2.2
    gatsby-transformer-remark: ^2.7.1 => 2.7.1
    gatsby-transformer-sharp: ^2.4.3 => 2.4.3
  npmGlobalPackages:
    gatsby-cli: 2.11.9

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 19
  • Comments: 17 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Hi! I had the exact same issue and fixed it by doing the following:

  • Updated my gatsby version to 2.20.24 by running npm update gatsby
  • Deleted my package-lock.json file
  • Ran npm install
  • npm run build finally stopped throwing the error you mentioned above

Thank you for opening this!

You shouldn’t install gatsby-cli in your Gatsby project as it’s not necessary. If you have the CLI globally installed and run gatsby develop inside a project it will use the local copy of the package. If you have not installed it globally you can use npm scripts.

I cloned your repository, removed the gatsby-cli dependency and package-lock.json file and run a npm install and npm run build without problems. The comment from Magnus reinforces that suspicion as he mentioned gatsby-cli himself.

We’re marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!

@LekoArts : Furthermore, if a patch version of gatsby-cli breaks gatsby then that is not a patch upgrade but a breaking change.

I had the same issue on gatsby@2.19.50, upgrading to latest (2.20.24) fixed it.

It took me a while to fix this error. I solved this by:

  • changing my gatsby version to 2.20.24 in package.json
  • deleting the package-lock.json file
  • doing a npm install

Now it’s fixed, thanks!

I was seeing the same issue in our ci after a package-lock file update, which worked fine locally. gatsby-cli is not in in package.json, but added to package-lock.json as dependency of gatsby.

Bumping gatsby version to 2.20.24 (and clean reinstall, reset of package-lock) solved it for me as well. I never saw this on my local environment though.

Hi! I had the exact same issue and fixed it by doing the following:

  • Updated my gatsby version to 2.20.24 by running npm update gatsby
  • Deleted my package-lock.json file
  • Ran npm install
  • npm run build finally stopped throwing the error you mentioned above

You must not delete package-lock.json neither update package(-lock).json manually! Otherwise, you’re getting even more weird problems)

Thank you for opening this!

You shouldn’t install gatsby-cli in your Gatsby project as it’s not necessary. If you have the CLI globally installed and run gatsby develop inside a project it will use the local copy of the package. If you have not installed it globally you can use npm scripts.

Thanks for the quick reply!

Personally I think that installing a project specific CLI into global node_modules is bad practice. When a project depends on a CLI for build/dev I will usually add it to devDependencies and have rarely ran into issues doing so. Anyhow since it’s listed in gatsby dependencies it will be pulled in when installing gatsby as you say. However, I believe it could theoretically cause problems with resolving the module if other packages also depend on it. I would argue for moving it to {dev,peer}Dependencies in order to avoid silent dependency errors like this.

I’m also experiencing the same issue, but only have gatsby-cli installed globally. Checking package.json, there’s no entry for gatsby-cli there, deleting node_modules and reinstalling, also deleting package-lock.json did not bring any different results.

your gatsby-cli installed globally, try reinstall it

In my company we got also problem with that error. (but we do not have gatsby-cli in deps) It was solved by update all packages related with gatsby to the newest versions.