javascript - React import problem, 'Module not found: Can't resolve' - Stack Overflow

I have a folder system in my React project, which you can see in the screenshot below:I am trying to ma

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 badges
Add a ment  | 

4 Answers 4

Reset to default 2

It'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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信