I am using React, and am trying to access a resource that is not in the src
directory, this results in an error.
Question
Is it possible to access a .js
(i.e. index.js
) file that is outside the src
directory?
I have the following directory structure:
- client
- src
- App.js
- data
- index.js
index.js
const ShiftList = [
{... data ...}
]
module.exports = { ShiftList }
App.js
import { ShiftList } from '../../data/index.js';
I get the following error:
./src/App.js Module not found: You attempted to import ../../data/index which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.