I have a react app that uses parcel instead of webpack and I wanted to add absolute paths into the project so I followed this guide and it works perfectly (you can ctr click
on the path and it finds it( BUT parcel is not happy with this because it cant resolve the path of the file if you say
/components/thisComponent/thisComponent.jsx
it says this instead
@parcel/resolver-default: Cannot load file '../../../thisComponent/thisComponent' in './src/thisComponent/thisComponent'.
💡 Did you mean '../../thisComponent/thisComponent'?
💡 Did you mean '../../../.thisComponents/thisComponents'?
is I tried using the ~
instead but that doesnt work as well. How can I use absolute paths with parcel ?
This has worked for me:
import {Button} from '../../../../../shared';
// changed to:
import {Button} from '~src/shared';
jsconfig.json
:
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}