Reputation: 25
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/components/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\components\KeyboardCard'.
Help me please.
Upvotes: 0
Views: 3175
Reputation: 83
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.
Upvotes: 1
Reputation: 1227
You have provided the wrong path.
import AppContext from '../../context.js';
Upvotes: 2
Reputation: 55623
It's two levels higher:
import AppContext from '../../context';
Upvotes: 2
Reputation: 8412
You can't have triple dots import there, try:
import AppContext from '../../context.js';
Upvotes: 2