当前位置: 首页 > article >正文

启动本地开发环境(自带热启动)yarn serve

文章目录

      • 1. 安装 Yarn
        • 使用 npm 安装 Yarn
        • 使用 Chocolatey 安装 Yarn(Windows 用户)
        • 使用 Homebrew 安装 Yarn(macOS 用户)
      • 2. 安装项目依赖
      • 3. 启动项目
        • 开发模式启动
        • 生产模式启动
      • 4. 构建项目
        • 开发模式构建
        • 生产模式构建
      • 5. 其他常用命令
      • 6. 部署到 OSS
        • 部署开发环境构建结果
        • 部署生产环境构建结果
      • 7. 同时部署开发和生产环境
      • 8. 运行 ESLint 检查
      • 总结

要使用 Yarn 启动你提供的项目,可以按照以下步骤进行操作:
package.json

{
  "name": "order-mid-manage",
  "version": "1.0.0",
  "private": true,
  "author": "沙漏",
  "scripts": {
    "serve": "concurrently \"vue-cli-service serve\"",
    "dev": "concurrently \"vue-cli-service serve\"",
    "serve:dev": "concurrently \"vue-cli-service serve  --mode development\"",
    "serve:prod": "concurrently \"vue-cli-service serve  --mode production\"",
    "build": "vue-cli-service build",
    "build:dev": "vue-cli-service build --mode development",
    "dev-to-oss": "node deploy.js dat",
    "build:dev-to-oss": "vue-cli-service build --mode development && node deploy.js dat",
    "build:prod": "vue-cli-service build --mode production",
    "prod-to-oss": "node deploy.js prod",
    "build:prod-to-oss": "vue-cli-service build --mode production && node deploy.js prod",
    "oss:all": "yarn build:dev-to-oss && yarn build:prod-to-oss",
    "build:stage": "vue-cli-service build --mode staging",
    "lint": "vue-cli-service lint",
    "mock": "cd mock && ts-node-dev mock-server.ts",
    "svg": "vsvg -s ./src/icons/svg -t ./src/icons/components --ext ts --es6",
    "test:e2e": "vue-cli-service test:e2e",
    "test:unit": "jest --clearCache && vue-cli-service test:unit"
  },
  "dependencies": {
    "@tinymce/tinymce-vue": "^3.1.0",
    "@types/moment": "^2.13.0",
    "@types/swiper": "^6.0.0",
    "ali-oss": "^6.17.1",
    "axios": "^0.19.2",
    "clipboard": "^2.0.4",
    "codemirror": "^5.51.0",
    "core-js": "^3.6.4",
    "cors": "^2.8.5",
    "default-passive-events": "^2.0.0",
    "dotenv-cli": "^6.0.0",
    "draggable": "^4.2.0",
    "driver.js": "^0.9.8",
    "echarts": "^5.4.2",
    "element-ui": "^2.15.11",
    "faker": "^4.1.0",
    "file-saver": "^2.0.2",
    "fuse.js": "^3.4.6",
    "js-cookie": "^2.2.1",
    "jsonlint": "^1.6.3",
    "jszip": "^3.2.2",
    "lodash": "^4.17.15",
    "morgan": "^1.9.1",
    "normalize.css": "^8.0.1",
    "nprogress": "^0.2.0",
    "path-to-regexp": "^6.1.0",
    "register-service-worker": "^1.6.2",
    "screenfull": "^5.0.1",
    "script-loader": "^0.7.2",
    "simple-progress-webpack-plugin": "^1.1.2",
    "sortablejs": "^1.10.2",
    "swiper": "^10.0.4",
    "tinymce": "^5.1.6",
    "vue": "^2.6.11",
    "vue-awesome-swiper": "^5.0.1",
    "vue-class-component": "^7.2.2",
    "vue-clipboard2": "^0.3.1",
    "vue-count-to": "^1.0.13",
    "vue-i18n": "^8.15.3",
    "vue-image-crop-upload": "^2.5.0",
    "vue-property-decorator": "^8.4.0",
    "vue-router": "^3.1.5",
    "vue-splitpane": "^1.0.6",
    "vue-svgicon": "^3.2.6",
    "vue2-dropzone": "^3.6.0",
    "vuedraggable": "^2.24.3",
    "vuex": "^3.1.2",
    "vuex-module-decorators": "^0.16.1",
    "wangeditor": "^4.7.7",
    "xlsx": "^0.15.5",
    "yamljs": "^0.3.0"
  },
  "devDependencies": {
    "@types/clipboard": "^2.0.1",
    "@types/codemirror": "^0.0.84",
    "@types/compression": "^1.7.0",
    "@types/cors": "^2.8.6",
    "@types/echarts": "^4.4.3",
    "@types/express": "^4.17.2",
    "@types/faker": "^4.1.9",
    "@types/file-saver": "^2.0.1",
    "@types/jest": "^25.1.2",
    "@types/js-cookie": "^2.2.4",
    "@types/jszip": "^3.1.7",
    "@types/lodash": "^4.14.149",
    "@types/morgan": "^1.7.37",
    "@types/node": "^13.7.0",
    "@types/nprogress": "^0.2.0",
    "@types/sortablejs": "^1.10.6",
    "@types/tinymce": "^4.5.23",
    "@types/webpack-env": "^1.15.1",
    "@types/yamljs": "^0.2.30",
    "@vue/cli-plugin-babel": "^4.2.2",
    "@vue/cli-plugin-e2e-cypress": "^4.2.2",
    "@vue/cli-plugin-eslint": "^4.2.2",
    "@vue/cli-plugin-pwa": "^4.2.2",
    "@vue/cli-plugin-router": "^4.2.2",
    "@vue/cli-plugin-typescript": "^4.2.2",
    "@vue/cli-plugin-unit-jest": "^4.2.2",
    "@vue/cli-plugin-vuex": "^4.2.2",
    "@vue/cli-service": "^4.2.2",
    "@vue/eslint-config-standard": "^4.0.0",
    "@vue/eslint-config-typescript": "^4.0.0",
    "@vue/test-utils": "^1.0.0-beta.31",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^10.0.3",
    "concurrently": "^5.1.0",
    "eslint": "^6.8.0",
    "eslint-plugin-vue": "^6.1.2",
    "fibers": "^4.0.2",
    "jest": "^25.1.0",
    "lint-staged": "^10.0.7",
    "sass": "~1.26.5",
    "sass-loader": "^8.0.2",
    "style-resources-loader": "^1.3.3",
    "swagger-routes-express": "^3.1.2",
    "ts-jest": "^25.2.0",
    "ts-node-dev": "^1.0.0-pre.44",
    "typescript": "^3.7.5",
    "vue-cli-plugin-element": "^1.0.1",
    "vue-cli-plugin-style-resources-loader": "^0.1.4",
    "vue-template-compiler": "^2.6.11",
    "webpack": "^4.41.5"
  },
  "gitHooks": {
    "pre-commit": "lint-staged"
  },
  "keywords": [
    "vue",
    "typescript",
    "admin",
    "template",
    "element-ui"
  ],
  "lint-staged": {
    "*.{js,vue}": [
      "vue-cli-service lint"
    ]
  }
}

1. 安装 Yarn

首先,确保你已经安装了 Yarn。如果没有安装,可以通过以下命令安装:

使用 npm 安装 Yarn
npm install -g yarn
使用 Chocolatey 安装 Yarn(Windows 用户)
choco install yarn
使用 Homebrew 安装 Yarn(macOS 用户)
brew install yarn

2. 安装项目依赖

进入项目目录,然后使用 Yarn 安装项目依赖:

cd path/to/your/project
yarn install

3. 启动项目

项目依赖安装完成后,你可以使用以下命令启动项目:

开发模式启动
yarn serve

或者使用 dev 脚本:

yarn dev
生产模式启动
yarn serve:prod

4. 构建项目

如果你需要构建项目,可以使用以下命令:

开发模式构建
yarn build:dev
生产模式构建
yarn build:prod

5. 其他常用命令

  • 运行单元测试

    yarn test:unit
    
  • 运行端到端测试

    yarn test:e2e
    
  • 启动 Mock 服务器

    yarn mock
    
  • 生成 SVG 图标组件

    yarn svg
    

6. 部署到 OSS

如果你需要将构建结果部署到 OSS,可以使用以下命令:

部署开发环境构建结果
yarn build:dev-to-oss
部署生产环境构建结果
yarn build:prod-to-oss

7. 同时部署开发和生产环境

如果你想同时部署开发和生产环境的构建结果,可以使用以下命令:

yarn oss:all

8. 运行 ESLint 检查

yarn lint

总结

通过以上步骤,你可以使用 Yarn 成功启动和管理你的项目。Yarn 的命令与 package.json 中的脚本定义一致,因此你可以直接使用 yarn <script-name> 来运行对应的脚本。

在这里插入图片描述


http://www.kler.cn/a/391150.html

相关文章:

  • 24.11.13 Javascript3
  • Spring Cloud Contract快速入门Demo
  • JavaScript高级程序设计基础(四)
  • 深度学习之 LSTM
  • 2024 kali操作系统安装Docker步骤
  • 前端Cypress自动化测试全网详解
  • Pytorch学习--神经网络--完整的模型验证套路
  • MacOS编译hello_xr——记一次CMake搜索路径限制导致的ANDROID_NATIVE_APP_GLUE not found
  • 网络安全-Linux基础(2)
  • 电子应用产品设计方案-5:多功能恒温控制器设计
  • 【主机游戏】正当防卫3游戏介绍
  • uniapp和uview-plus组件在项目中向后端发起请求的封装
  • 【蓝桥等考C++真题】蓝桥杯等级考试C++组第13级L13真题原题(含答案)-统计数字
  • 用轻量云服务器搭建一个开源的商城系统,含小程序和pc端
  • Java中的不可变集合:性能与安全并重的最佳实践
  • 力扣 LeetCode 977. 有序数组的平方(Day1:数组)
  • qt ui设计案例--登录界面
  • 【AI日记】24.11.08 Knowledge Graphs for RAG (知识图谱,Neo4j,Cypher)
  • Go/Golang语言各种数据类型内存字节占用大小和最小值最大值
  • NVR批量管理软件/平台EasyNVR多个NVR同时管理基于端-边-云架构的智能视频融合云平台
  • golang分布式缓存项目 Day1 LRU 缓存淘汰策略
  • CatBoost中的预测偏移和排序提升
  • 数据结构-递归函数的调用栈过程
  • 如何编写jenkins的流水线
  • DB-GPT系列(四):DB-GPT六大基础应用场景part1
  • C#中Task和Thread的全解析