Ken的杂谈
  • Ken的杂谈 (current)
  • 关于
  • 杂谈
    Java Spring Spring Boot Spring Cloud MyBatis C# .NET Core .NET ASP.NET Core ASP.NET ClassLibrary Mono 数据库 MySQL SQL Server 网络 缓存 Web Linux CentOS Ubuntu macOS Windows openEuler Nginx ServiceStack JS/JQ 正则 工具 IDE Grafana Exceptions CI/CD Solution 微服务 Arch Docker 杂谈
  • 系列
    Java 快速入门系列教程 Spring Boot 入门教程 Spring Boot 2.x 入门教程 Spring Cloud 入门教程 .NET Core 快速入门教程 ASP.NET Core 2.1 入门教程 CentOS 7 快速上手教程 Ubuntu快速上手入门教程 Hyper-V基础教程 Docker入门教程
  • GitHub

Vue入门 - 环境搭建&项目初始化(HelloWorld)

Web @ 2021-10-02 12:21:11 · 阅读:(4348)

一、nodejs安装

访问 https://nodejs.org/en/ ,下载并安装LTS版本

Windows建议安装在 C:\nodejs目录

image

查看node安装版本,验证是否安装成功

node -v

二、Vue环境安装

1、更换NPM源

npm config set registry https://registry.npmmirror.com --global

2、Vue安装

  • Vue 2.x安装
npm install -g vue-cli
  • Vue 3.x安装
npm install -g @vue/cli
npm i -g @vue/cli-init

三、webpack安装

npm install -g webpack

四、Hello World

1、项目初始化

  • Vue 2.x
d: && cd d:\projects
vue init webpack vuedemo
? Project name vuedemo
? Project description A Vue.js project
? Author Ken <m@ken.io>
? Vue build standalone
? Install vue-router? Yes
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Set up unit tests Yes
? Pick a test runner jest
? Setup e2e tests with Nightwatch? No
? Should we run `npm install` for you after the project has been created? (recommended) npm

   vue-cli · Generated "vuedemo".


# Installing project dependencies ...
# ========================
  • Vue 3.x

通过Vue CLI初始化项目

d: && cd d:\projects
vue create vuedemo

Vue-Cli提供了三个选项,这里我们选择第2个即可

Vue CLI v4.5.13
? Please pick a preset: (Use arrow keys)
  Default ([Vue 2] babel, eslint)
> Default (Vue 3) ([Vue 3] babel, eslint)
  Manually select features

2、项目运行

  • 进入项目命令并安装项目依赖
cd vuedemo
npm install
  • 项目运行
#vue 2.x
npm run dev

#vue 3.x
npm run serve

image

访问:http://localhost:8080

image

五、可能碰到的问题

1、node命令不存在

解决办法:配置环境变量PATH,增加:C:\Program Files\nodejs

2、安装vue-cli报错

permissions of the file and its containing directories, or try running, the command again as root/Administrator.

解决办法:使用sudo命令


Ken的杂谈

本文由 ken.io 创作,采用CC BY 3.0 CN协议 进行许可。 可自由转载、引用、甚至修改,但需署名作者且注明出处。

Web

随笔目录


    © Copyright 2012-2025 Ken的杂谈

    豫ICP备10025012号

    ASP.NET Core(6.0) on Linux