I have a folder system in my React project, which you can see in the screenshot below:
I am trying to make import to index.js
, located in src/ponents/KeyboardCard/index.js
, from file context.js
that is located in src/context.js
.
I am getting this error message:
Module not found: Can't resolve '.../context.js' in 'C:\React\top-board\src\ponents\KeyboardCard'.
Help me please.
I have a folder system in my React project, which you can see in the screenshot below:
I am trying to make import to index.js
, located in src/ponents/KeyboardCard/index.js
, from file context.js
that is located in src/context.js
.
I am getting this error message:
Module not found: Can't resolve '.../context.js' in 'C:\React\top-board\src\ponents\KeyboardCard'.
Help me please.
Share Improve this question edited Aug 14, 2021 at 3:13 rmlockerd 4,1362 gold badges20 silver badges28 bronze badges asked Aug 13, 2021 at 11:32 ТимурТимур 252 silver badges5 bronze badges4 Answers
Reset to default 2It's two levels higher:
import AppContext from '../../context';
You can't have triple dots import there, try:
import AppContext from '../../context.js';
You have provided the wrong path.
import AppContext from '../../context.js';
If you want to go 2 levels higher you have to do it like this:
../../context
Also, you don't have to define file format ".js" there, that's not required.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745366720a4624614.html
评论列表(0条)