1

I am stuck with whit compile-time error:

Failed to compile.

./node_modules/@restart/context/forwardRef.js
Module not found: Can't resolve 'react' in 'C:\IdeaProjects\ai\node_modules\@restart\context'

The app has stopped to work suddenly, removing existing changes from last working iteration didn't help. Folder "../node_modules/@restart/context" is in place and is not empty. I tried to deleting package-lock.json and reinstalling, removing all modules and reinstalling, the error persisted.

How can I solve the situation?

App.js:

import React from 'react';
import './App.css';
import {Trans, withTranslation} from 'react-i18next'
import {Header} from "./components/Header";
import {C2A} from "./components/C2A";
import {DecorationOptions} from "./components/DecorationOptions";
import {ImagesGallery} from "./components/SwipeGallery";


function App({t}) {
    return (
    <div id="main">
        <Header/>
        <div className="text_wrapper">
            <p><Trans i18nKey='intro1'/></p>
            <p><Trans i18nKey='intro2'/></p>
            <C2A/>
        </div>

        <div id="bg-img1" className="background_image" />

        <DecorationOptions/>

        <div id="bg-img2" className="background_image"/>

        <ImagesGallery/>

        <div id="temp_separator">
        </div>
    </div>
  );
}

export default withTranslation('common')(App);

package.json:

{
  "name": "ai",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "bootstrap": "^4.3.1",
    "i18next": "^17.0.11",
    "i18next-browser-languagedetector": "^3.0.3",
    "react-bootstrap": "^1.0.0-beta.11",
    "react-dom": "^16.9.0",
    "react-i18next": "^10.12.2",
    "react-image-gallery": "^0.9.1",
    "react-scripts": "3.1.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
4
  • Have you tried the (roughly) canonical solution of blowing away node_modules and re-installing? Commented Sep 16, 2019 at 12:48
  • 2
    Your package.json is missing the react dependency, simply run npm install react --save Commented Sep 16, 2019 at 12:48
  • @GiladBar: You were right, thanks a lot! Would you like to write an answer? Do you have any idea how the change could have happened? Commented Sep 16, 2019 at 13:02
  • Yeah, I will :) Commented Sep 16, 2019 at 13:12

2 Answers 2

2

Your package.json is missing the react dependency, simply run npm install react --save. Basically there's no reason or anything that can remove this dependency from the package.json, other than deleting it or running npm remove react

Sign up to request clarification or add additional context in comments.

1 Comment

I have still no idea how the removal could have happened. Thanks a lot for your help!
0

Try npm install react which is missing in your dependencies of package.json.

Consider using create-react-app as a react boilerplate.

1 Comment

I have used CRA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.