Absolute Path Work On A React Project Installation, But Fails On Another. Why?
I create a project with create-react-app and do many staff on my office. On my imports im using no relative path on folders:
project-folder
src
components
reducer
On my reducer folder i made a import like this:
import componentX from "components/mycommponent/componentX"
and on my office, works without problem.
On my home, i just download the project do 'npm install' a try to run the project
and the same file don't find the componentX and i don´t know why. I have several imports on that project and, if possible, don't want to change all my imports.
Can you guy know why this happen?
Answer
At the root of the project create a .env
file... To that file add NODE_PATH=src/
Now you do not need to use relative imports... (Note: since I don't know the exact directory structure of your project use some common sense and adapt the solution to your specific situation)
My guess would be that said .env
file is probably in the .gitignore
and you didn't get it when cloning the repo...
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM