我正在使用MERN堆栈开发一个应用程序。后端和前端位于具有以下层次结构的同一存储库中:
my-project/
├── backend/
│ │
│ .
│ .
│ └── package.json
├── frontend/
│ │
│ .
│ .
│ └── package.json
├── shared/
│ ├── constants/
│ .
│ .
│ ├── index.js
│ └── package.json
├── package.json
└── README.md
我希望在后端和前端之间共享我的常量。我在共享文件夹/模块中有常量。
我还希望共享软件包中的任何更改都能反映在其他软件包中,而无需重新安装。
后端和前端使用共享包作为依赖项的最佳方式是什么?
您的目录结构几乎可以使用。但可能存在一些缺陷
my-project/
├── backend/
│ │
│ .
│ .
│ └── package.json
├── frontend/
│ │
│ .
│ .
│ └── package.json
├── shared/
│ ├── constants/
│ .
│ .
│ ├── index.js
│ └── package.json // You might not need this
├── package.json // define shared packages here
└── README.md
更多细节,如何节点