Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find file: 'index.js' does not match the corresponding name on disk: '.\node_modules\React\react' error with React import correct

I am getting the below error on a page that is stopping it being rendered and after checking other similar errors I have double checked the import is correct and the node_modules react index file is installed.

What else could be causing this? I have had linting issues yesterday out of nowhere that I thought had fixed themselves.

The file this refers to should be node_modules/React/react.indexjs but on my system is node_modules/react.index.js. I haven't changed this myself so i'm not sure where it has come from. I have also removed any code that was added to this file which could of been causing it.

Cannot find file: 'index.js' does not match the corresponding name on disk: '.\node_modules\React\react'

enter image description here

enter image description here

like image 533
James Gee Avatar asked Jul 15 '26 02:07

James Gee


1 Answers

This happens when you import react like this

import React from "React"

notice the capital R

instead, you should do :

import React from "react"

( with a small r )

like image 58
Taki Avatar answered Jul 19 '26 02:07

Taki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!