首页 > 解决方案 > What is the correct way of handling dependencies if back end and front end code is in the same repository?

问题描述

I have got a project where the back end Node.js and the front end Vue.js code is in the same repository.

They share dependencies via package.json. There are common dependencies needed for both parts, and there dependencies specific either to the front end part or to the back end part.

How the project is built and run:

The front end part is built with:

npm install
npm run build

After this the front end part is compiled to dist folder and then put into a docker image where the server would run it. The server code and node_modules are also put to the same image and then the server is run with:

npm run start

Problem:

Because of the shared dependencies the node_modules folder (needed to run the server part) includes the front end dependencies which makes it ridiculously huge. I manged to decrease the size by excluding dev depnedencies via npm install --only=production, but I would prefer not having to manage them at all.

Questions:

标签: javascriptnode.jsnpm

解决方案


推荐阅读