my project was created by the command npx create-react-app last year. I have just tried to apply your solution of importing other components. However, i still get the message "Module not found: Can't resolve '...". it looks like the import by this way is correct because i can jump into the component by pressing ctrl + left mouse click into the path. so i don't know why compiler doesn't recognize the new import path. have you ever bump into this kind of issue ? and what is your solution to cover this case ?
Hi, that solution works only with projects created using create-react-app in version 3 (released in April 2019). If your project was bootstrapped with v2 you can use old school way to achieve absolute imports. Create .env file with that line NODE_PATH=src/. That should work for you.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
my project was created by the command npx create-react-app last year. I have just tried to apply your solution of importing other components. However, i still get the message "Module not found: Can't resolve '...". it looks like the import by this way is correct because i can jump into the component by pressing ctrl + left mouse click into the path. so i don't know why compiler doesn't recognize the new import path. have you ever bump into this kind of issue ? and what is your solution to cover this case ?
Hi, that solution works only with projects created using create-react-app in version 3 (released in April 2019). If your project was bootstrapped with v2 you can use old school way to achieve absolute imports. Create
.env
file with that lineNODE_PATH=src/
. That should work for you.