javascript - 在 MERN 存储库中设置共享文件夹
问题描述
我正在使用 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
更多细节,如何节点
推荐阅读
- tensorflow - Python内核在加载预训练的YOLO模型时死亡
- ios - 有什么办法可以改变 iOS 大标题的左边距?
- java - 如何在不同的类中使用变量而不改变它
- python - Python pyinstaller 编译代码失败,返回“未找到‘加密’分布,应用程序需要它”
- java - 创建 maven 项目时出现 pom.xml 错误
- angular - cloudinaryJsLib.Cloudinary 不是构造函数 Angular 6 Cloudinary
- javascript - 完成所有异步函数后,如何确保再次调用间隔函数?
- python - PySpark - 拒绝主连接
- python - 从多个模型中解析 Rasa NLU
- excel - 将文件的每一行与第二个文件中的数千行进行比较时提高速度