Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I run into these errors when running my Gatsby development server?

I'm completing Gatsby's part three tutorial from their official website and running into a problem.

First when I gatsby new tutorial-part-three https://github.com/gatsbyjs/gatsby-starter-hello-world

I get those errors in terminal:

warning "gatsby > [email protected]" has unmet peer dependency "@types/react@^15.0.0 || ^16.0.0".
warning "gatsby > @typescript-eslint/eslint-plugin > [email protected]" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".

However I can still get running the website in localhost:8000. The real problem arises when I follow the tutorial and install the Typography plugin using this command :

npm install --save gatsby-plugin-typography react-typography typography typography-theme-fairy-gates

Here are the errors I get :

npm WARN [email protected] requires a peer of react@^16.4.2 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @reach/[email protected] requires a peer of [email protected] || 16.x || 16.4.0-alpha.0911da3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^16.4.2 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@>=16.8.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^16.8.2 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^16.0.0 but none is installed. You must install peer dependencies yourself.

Then when I try to start the development server using gatsby develop I get these fatal errors:

The above error occurred in the <StoreStateProvider> component:
    in StoreStateProvider
    in App

React will try to recreate this component tree from scratch using the error boundary you provided, App.
Warning: App: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.
  Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
  See https://fb . me/react-invalid-hook-call for tips about how to debug and fix this problem.

I would really appreciate some help making sense of this ! Sorry if my question is not well formulated, this is my first time using Stack Overflow.

edit: package.json

{
  "name": "gatsby-starter-hello-world",
  "private": true,
  "description": "A simplified bare-bones starter for Gatsby",
  "version": "0.1.0",
  "license": "MIT",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{js,jsx,json,md}\"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
  },
  "dependencies": {
    "gatsby": "^2.18.4",
    "react": "^16.12.0",
    "react-dom": "^16.12.0"
  },
  "devDependencies": {
    "prettier": "^1.19.1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gatsbyjs/gatsby-starter-hello-world"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  }
}
like image 896
Andréa Avatar asked Dec 07 '19 13:12

Andréa


People also ask

Why am I getting so many errors in Gatsby develop?

Many errors you encounter will mean adjusting how you’ve configured a plugin or API in your site. This guide is meant as a reference for common errors that have tripped up other Gatsby users. Running a site in gatsby develop will set up a server locally that enables features like hot-module replacement.

Why can't I find the file in Gatsby build?

The build is failing to find the file at ../..SomeFile.svg. This can be frustrating if your site works when you when run it locally with gatsby develop, and even works when you run gatsby build and gatsby serve locally. A likely problem is that the operating system you are running locally is different than the one where your site is deployed.

Why run a site in Gatsby?

Running a site in gatsby develop will set up a server locally that enables features like hot-module replacement. Gatsby keeps a cache of data and rendered assets in the .cache folder at the root of a Gatsby site so that it doesn’t have to repeat work processing optimized resources.

Why does my Gatsby build look different when using CSS-in-JS?

Because gatsby develop doesn’t run server-side rendering, the build may look different if the plugin is not included to tell Gatsby to server-side render the styles for the CSS-in-JS solution being used.


2 Answers

For anyone having that problem, found the answer here.

The solution is to replace the command npm install --save gatsby-plugin-typography react-typography typography to the yarn equivalent yarn add gatsby-plugin-typography react-typography typography

like image 189
Andréa Avatar answered Sep 23 '22 01:09

Andréa


From this issue, it seems like you can simply clean out your existing node_modules and reinstall.

$ rm -rf node_modules package-lock.json
$ npm install
like image 43
Brady Dowling Avatar answered Sep 19 '22 01:09

Brady Dowling