I am working on an application using the MERN stack. The backend and frontend are in the same repository with this hierarchy:
my-project/
├── backend/
│ │
│ .
│ .
│ └── package.json
├── frontend/
│ │
│ .
│ .
│ └── package.json
├── shared/
│ ├── constants/
│ .
│ .
│ ├── index.js
│ └── package.json
├── package.json
└── README.md
I want to have my constants shared between both the backend and frontend. I have the constants in the shared folder/module.
I also want to have any change in the shared package to be reflected in the other packages without needing to reinstall.
What is the best way for both the backend and frontend to use the shared package as a dependency?