# 环境准备 以及 安装

# 开发环境准备

  • Node.js 版本 最好等于或者大于 16 以上
  • 包管理工具, npm >= 5.0.0 或者 Yarn (opens new window) 1.x 版本都可以
  • 终端环境推荐使用 bash 或者 zsh,如果你是 Windows 环境,推荐使用 git-bash (默认 git 客户端已经自带了 git-bash)
  • 编辑器没有特别要求, 推荐使用 VSCode, 如果你使用的是 TS 版本的话, VSCode 对代码提示有良好的支持

# 脚手架 安装步骤

# 1.配置私有源 @ubtech

以下提供几种方式配置私有源

  • 第一种,使用 npm config 强烈推荐
npm config set @ubtech:registry https://edu-registry.ubtrobot.com:9601

检查配置

设置之后如果不生效, 使用这个检查一下是否带有该配置, 或者是否正确

npm config get @ubtech:registry
  • 第二种,修改全局 .npmrc 配置文件

~/.npmrc 添加这一行, 如果是 windows 则在 %userprofile%\.npmrc

@ubtech:registry=https://edu-registry.ubtrobot.com:9601
  • 第三种,使用环境变量 npm_config_registry
使用环境变量

还有另外一种配置源的方法, 就是使用环境变量, 如果不想改变全局的配置, 或者在 Jenkins 一些 CI 环境里面, 比较合适

设置环境变量 npm_config_registryhttps://edu-registry.ubtrobot.com:9601

如 Shell 环境下:

export npm_config_registry=https://edu-registry.ubtrobot.com:9601

也可以临时使用环境变量, 一句指令解决

  • shell 环境 (bash/git-bash/zsh/ksh 等)
npm_config_registry=https://edu-registry.ubtrobot.com:9601 npx @ubtech/create-ucode-extension
  • powershell/CMD 环境
npx cross-env npm_config_registry=https://edu-registry.ubtrobot.com:9601 npx @ubtech/create-ucode-extension

# 2.使用 npx 指令

配置完 @ubtech 源之后, 只需要使用 npx 指令, 就可以调用脚手架了, 第一次使用, 可能会提醒安装

npx @ubtech/create-ucode-extension
国内源加速

如果你遇到安装非常缓慢, 是因为网络源的问题, 默认 npm 或者 yarn 是走官方的源, 如果在中国海内, 建议使用 淘宝的源 (opens new window)

你可以先设置这个源

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

# 交互界面

运行脚手架命令行指令之后,会有如下界面, 属于一种可互动的命令行的交互界面,你可以根据你的选择去创建的的项目

可以看以下录屏(点击播放)

目前脚手架支持的特性有:

特性
本地载入
调试
uCode 公共 SDK
自定义 UI
TypeScript 类型支持
代码校验