简体   繁体   English

如何在存储库中安装 vue.js?

[英]How to install vue.js inside a repository?

I have a project with a backend and frontend repository.我有一个带有后端和前端存储库的项目。 The frontend utilizes vue.js.前端使用 vue.js。

Now, I can easily clone the git repository onto my local machine.现在,我可以轻松地将 git 存储库克隆到我的本地机器上。 There I need to run it.在那里我需要运行它。 To do this, I first need to set up vue.js inside the repository...somehow, I guess.为此,我首先需要在存储库中设置 vue.js...不知何故,我猜。 The repository doesnt have any node or npm or whatever stuff in it.存储库中没有任何节点或 npm 或任何东西。 I need to install this myself, locally (I guess this was done to protect the repository from growing too big).我需要自己在本地安装它(我想这是为了保护存储库不会变得太大)。

I learnt on the vue.js official sites how to create a new project, but in this case, I'm working in an existing project, right?我在 vue.js 官方网站上学习了如何创建一个新项目,但在这种情况下,我在一个现有项目中工作,对吗? So how do I get vue.js into an existing project.那么如何将 vue.js 引入现有项目。 Its vue-cli based btw., so I need to install vue-cli as well (or rather use the vue-cli version of vue.js)顺便说一句,它是基于 vue-cli 的,所以我还需要安装 vue-cli(或者更确切地说是使用 vue.js 的 vue-cli 版本)

Okay, I found the answer myself.好吧,我自己找到了答案。

First, vue cli needs to be installed locally.首先需要在本地安装vue cli。 So inside cmd cd to your local repository and execute:所以在 cmd cd 到您的本地存储库并执行:

npm install vue-cli

After this, install the serve functionality like this:在此之后,像这样安装服务功能:

npm install -g serve

and then you can just do:然后你可以这样做:

serve

And you get something like this on your cmd:你在你的 cmd 上得到这样的东西:

   │   Serving!                                        │
   │                                                   │
   │   - Local:            http://localhost:5000       │
   │   - On Your Network:  http://172.21.128.28:5000   │
   │                                                   │
   │   Copied local address to clipboard!              │

Optionally, you can also first build your project and then serve your dist, so after install your serve functionality, first do:或者,您也可以先构建您的项目,然后为您的 dist 提供服务,因此在安装您的服务功能后,首先执行:

npm run build

and then进而

serve -s dist

and you should be fine.你应该没事的。 You can read about some of this stuff here too: https://cli.vuejs.org/guide/deployment.html#general-guidelines您也可以在这里阅读其中的一些内容: https : //cli.vuejs.org/guide/deployment.html#general-guidelines

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM