I am trying to create absolute import for react but im keep getting this error:
ERROR in ./src/pages/IndexPage.jsx
Module not found: Error: Can't resolve '@components' in '/Users/nhannguyen/Desktop/sites/hawk-ridge-systems/pwa/src/pages'
ℹ 「wdm」: Failed to compile.
Here is my project structure:
jsconfig.json`:
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@": ["./src"],
"@components": ["./src/components"]
}
},
"include": ["./src/**/*"]
}
and here is code that I tried to import:
import React from 'react';
import { HomePage } from '@components';
const IndexPage = () => {
return (
<>
<HomePage />
</>
);
};
export default IndexPage;