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
- Update Gatsby to ^2.22.7 Fixes a TypeError https://github.com/gatsbyjs/gatsby/issues/23214 — committed to shreyasminocha/regex-for-regular-folk by shreyasminocha 4 years ago
- Remove redundant dependency as per https://github.com/gatsbyjs/gatsby/issues/23214#issuecomment-615113085 — committed to realrubberduckdev/dp-blog by realrubberduckdev 4 years ago
Hi! I had the exact same issue and fixed it by doing the following:
npm update gatsbynpm installnpm run buildfinally stopped throwing the error you mentioned aboveThank you for opening this!
You shouldn’t install
gatsby-cliin your Gatsby project as it’s not necessary. If you have the CLI globally installed and rungatsby developinside 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-clidependency and package-lock.json file and run anpm installandnpm run buildwithout 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-clibreaksgatsbythen 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:
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.
You must not delete package-lock.json neither update package(-lock).json manually! Otherwise, you’re getting even more weird problems)
Thanks for the quick reply!
Personally I think that installing a project specific CLI into global
node_modulesis bad practice. When a project depends on a CLI for build/dev I will usually add it todevDependenciesand have rarely ran into issues doing so. Anyhow since it’s listed ingatsbydependenciesit will be pulled in when installinggatsbyas 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}Dependenciesin order to avoid silent dependency errors like this.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.