在Ubuntu下部署Vue开发环境(详细流程)

在Ubuntu下部署Vue环境(很是详细流程)

本文做者:魏泯前端

博客源地址:https://www.cnblogs.com/simple/vue

效率魔法师node

咱们的需求是使用vue进行先后端分离开发,本节目标是为了可以使用npm run dev将咱们的前端项目运行起来
咱们须要的是nodejs、npm、cnpm、webpack、vuewebpack

个人Ubuntu版本: elementoryOS 5 (基于Ubuntu18)git

在Ubuntu下下载安装nodejs

更新包管理器apt与apt-getgithub

sudo apt update
sudo apt-get update

使用apt包管理器进行下载web

sudo apt-get install nodejs         # 下载nodejs
sudo apt-get install npm        #下载npm,它是nodejs的包管理器(nodejs package manager)

升级 npmvue-cli

npm install npm -g
# npm install -g npm
# npm -g install npm

国内的npm不是很好用,使用cnpm代替npm的平常使用。npm

升级或安装 cnpmubuntu

npm install cnpm -g

你能够使用如下命令来查看全部全局安装的模块:

$ npm list -g

请先安装git,安装命令请参考下面
ubuntu系统

sudo apt-get install git

安装Vue

最新稳定版

$ cnpm install vue

命令行工具

Vue.js 提供一个官方命令行工具,可用于快速搭建大型单页应用。

全局安装 vue-cli

$ cnpm install --global vue-cli

使用 cnpm 安装 webpack:

cnpm install webpack -g

建立一个基于 webpack 模板的新项目

$ vue init webpack my-project

这里须要进行一些配置,默认回车便可

This will install Vue 2.x version of the template.

For Vue 1.x use: vue init webpack#1.0 my-project

? Project name my-project
? Project description A Vue.js project
? Author runoob <test@runoob.com>
? Vue build standalone
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Setup unit tests with Karma + Mocha? Yes
? Setup e2e tests with Nightwatch? Yes

   vue-cli · Generated "my-project".

   To get started:
   
     cd my-project
     npm install
     npm run dev
   
   Documentation can be found at https://vuejs-templates.github.io/webpack

进入项目,安装并运行:

$ cd my-project
$ cnpm install      # 安装依赖
$ cnpm run dev      # 运行项目


 DONE  Compiled successfully in 4388ms

> Listening at http://localhost:8080

若有问题,请留言。 若有不足,请指正。

相关文章
相关标签/搜索