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

Created on 17 Apr 2020  路  17Comments  路  Source: gatsbyjs/gatsby

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
bug

Most helpful comment

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

All 17 comments

It seems like we are hitting similar issues on gatsby-cli-2.11.9 (upgrading from 2.11.5).

Getting the following stacktrace on gatsby develop:

  TypeError: Cannot read property 'activities' of undefined
  - utils.js:20 getGlobalStatus
    [app]/[gatsby-cli]/lib/reporter/redux/utils.js:20:54
  - internal-actions.js:137 Object.startActivity
    [app]/[gatsby-cli]/lib/reporter/redux/internal-actions.js:137:51
  - redux.js:483 Object.startActivity
    [app]/[redux]/lib/redux.js:483:35
  - reporter-timer.js:24 Object.start
    [app]/[gatsby-cli]/lib/reporter/reporter-timer.js:24:23
  - index.js:126 module.exports
    [app]/[gatsby]/dist/bootstrap/index.js:126:12
  - develop.js:429 module.exports
    [app]/[gatsby]/dist/commands/develop.js:429:36
  - task_queues.js:93 processTicksAndRejections
    internal/process/task_queues.js:93:5

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!

Oh, sorry for the false alarm and thank you for the quick reply!
The error is gone now after removing gatsby-cli from the dependencies.

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.

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.

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

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.

I had the same issue on [email protected], upgrading to latest (2.20.24) fixed it.

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

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.

Edit: Looks like I fixed this by downgrading to yarn add [email protected] and then doing yarn add gatsby
I have no idea why this worked, but it did. Hopefully this can help someone else!

I'm having a similar error. I've tried using npm, yarn, yarn upgrade, deleting yarn.lock, deleting package-lock.json, deleting node_modules, removing gatbsy-cli, installing gatsby-cli globally, adding the yarn PATH to .profile and .bashrc.
I do not see gatsby-cli listed in my package.json, but it is listed in the yarn.lock (or package-lock.json if I use npm).
My os is Ubuntu.

If I type gatsby -v in my project in terminal it shows:
Gatsby CLI version: 2.12.5
Gatsby version: 2.20.8
Note: this is the Gatsby version for the site at: /home/myname/WebstormProjects/myproject

It looks like this when I exit gatsby develop and it also gives me the error if I try to build either on my computer or on netlify.

Warning: App: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.

/usr/local/share/.config/yarn/global/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
throw ex;
^

TypeError: Cannot read property 'activities' of undefined
at getGlobalStatus (/usr/local/share/.config/yarn/global/node_modules/gatsby-cli/lib/reporter/redux/utils.js:20:54)
at createPendingActivity (/usr/local/share/.config/yarn/global/node_modules/gatsby-cli/lib/reporter/redux/internal-actions.js:108:51)
at /usr/local/share/.config/yarn/global/node_modules/redux/lib/redux.js:483:35
at prematureEnd (/usr/local/share/.config/yarn/global/node_modules/gatsby-cli/lib/reporter/catch-exit-signals.js:37:38)
at Reporter [as panic] (/usr/local/share/.config/yarn/global/node_modules/gatsby-cli/lib/reporter/reporter.js:71:42)
at process.on.reason (/usr/local/share/.config/yarn/global/node_modules/gatsby-cli/lib/index.js:136:21)
at process.emit (events.js:203:15)
at processEmit (/usr/local/share/.config/yarn/global/node_modules/signal-exit/index.js:161:32)
at processEmit [as emit] (/home/atlee/WebstormProjects/myproject/node_modules/signal-exit/index.js:161:32)
at emitPromiseRejectionWarnings (internal/process/promises.js:140:18)
at process._tickCallback (internal/process/next_tick.js:69:34)

This is the error on netlify:

10:55:08 PM: /opt/build/repo/node_modules/gatsby-cli/lib/reporter/redux/utils.js:20
10:55:08 PM: const currentActivities = [id, ...Object.keys(logs.activities)];
10:55:08 PM: ^
10:55:08 PM: TypeError: Cannot read property 'activities' of undefined
10:55:08 PM: at getGlobalStatus (/opt/build/repo/node_modules/gatsby-cli/lib/reporter/redux/utils.js:20:54)
10:55:08 PM: at createPendingActivity (/opt/build/repo/node_modules/gatsby-cli/lib/reporter/redux/internal-actions.js:108:51)
10:55:08 PM: at /opt/build/repo/node_modules/redux/lib/redux.js:483:35
10:55:08 PM: at prematureEnd (/opt/build/repo/node_modules/gatsby-cli/lib/reporter/catch-exit-signals.js:37:38)
10:55:08 PM: at Reporter [as panic] (/opt/build/repo/node_modules/gatsby-cli/lib/reporter/reporter.js:71:42)
10:55:08 PM: at process.on.error (/opt/build/repo/node_modules/gatsby-cli/lib/index.js:139:21)
10:55:08 PM: at process.emit (events.js:198:13)
10:55:08 PM: at processEmit [as emit] (/opt/build/repo/node_modules/signal-exit/index.js:161:32)
10:55:08 PM: at process._fatalException (internal/bootstrap/node.js:497:27)
10:55:08 PM: error Command failed with exit code 7.
10:55:08 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

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

Btw, gatsby-cli is still an explicit dependency of gatsby, so it gets installed locally no matter what. Am I missing something?

In my company the devOps time changed the node version inside Dockerfile and it worked. We are using here: Node 14.4.0

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!

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

This worked.
I removed the package-lock.json
I ran
npm uninstall gatsby-cli
npm install
npm update gatsby

Development ran fine. And gatsby build worked.

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)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rossPatton picture rossPatton  路  3Comments

mikestopcontinues picture mikestopcontinues  路  3Comments

magicly picture magicly  路  3Comments

andykais picture andykais  路  3Comments

totsteps picture totsteps  路  3Comments