0

Not sure if this is a bug?

Module not found: Can't resolve './react' in /Users/idea/hjgkh/robotsf/src even though I checked like hundreds of times

why am I keep getting this "Can't resolve './react' in" whenever Npm start.

Can someone please me help out here.


import React from './react';

const SearchBox =() => {
    return (
        <div className = 'pa2'> 
        <input
        className = 'pa3 ba b--green bg lightest-blue' 
        type = 'Search' 
        placeholder = 'Search Robots'
        />
        </div>
        );
}
export default SearchBox;
 
hRaze
  • 3
  • 2
  • It's a bug in your code, not react or npm. `import React from './react';` should be `import React from 'react';`. Its a node module, not a local file. – Brian Thompson Jul 09 '20 at 20:20

2 Answers2

0

React should be in your node_modules directory, leave out the dot from the import statement:

import React from 'react'

giraffesyo
  • 4,860
  • 1
  • 29
  • 39
0

Many possible reasons - most likely the package is not there, or the path to it is incorrect.

  1. Try import React from 'react'. Some setups will alias directly to the node_modules folder and require absolute paths to work.
  2. Are you using Webpack? Make sure the project is setup correctly Webpack + React
  3. Is react actually installed? Is it listed in package.json and have you installed it with npm install? Check npm documentation as well.