Can't resolve module (not found) in React.js

前端 未结 15 1376
太阳男子
太阳男子 2020-12-07 22:03

I can\'t believe that I\'m asking an obvious question, but I still get the error in console log.

Console says that it can\'t find the module in the directory, but I\

15条回答
  •  萌比男神i
    2020-12-07 22:19

    I was facing the same problem and I resolved it. See if your index.js file is in src folder, then what ever file you are importing, the folder containing that must also be inside the src folder.

    That means if your components folder is outside the src folder, just drag it inside the src folder in your editor because the files outside of src folder are not imported.

    Then you shall be able to import using ./components/header/header(in this case) enter image description here

提交回复
热议问题