安装
vue3项目使用 @94ai-plus/common-ui,vue2项目使用 @94ai/common-ui。
- @94ai-plus组件库基于vue3.5.44+element-plus@2.14.7
- @94ai组件库基于vue2.7.16+element-ui@2.15.14
阿里云私服授权源
在本机或 CI 使用以下 .npmrc 模板。公司的私库配置使用用户名和 Base64 密码认证;npm 公共源的 Token 不用于阿里云私库。
registry=https://registry.npmjs.org/
@94ai:registry=https://packages.aliyun.com/644f755a97d94d909e43534c/npm/npm-registry/
@94ai-plus:registry=https://packages.aliyun.com/644f755a97d94d909e43534c/npm/npm-registry/
//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}
//packages.aliyun.com/644f755a97d94d909e43534c/npm/npm-registry/:username=${NPM_PRIVATE_USERNAME}
//packages.aliyun.com/644f755a97d94d909e43534c/npm/npm-registry/:_password=${NPM_PRIVATE_PASSWORD_BASE64}
//packages.aliyun.com/644f755a97d94d909e43534c/npm/npm-registry/:always-auth=true由公司管理员提供 NPM_PRIVATE_USERNAME、NPM_PRIVATE_PASSWORD_BASE64;后者是私库要求的 Base64 密码,不是明文密码。仅使用私库、不访问 npm 受保护资源时,可以省略公共源 _authToken 一行。已有有效私库 Token 的环境也可按 registry 要求使用 _authToken,不要与用户名/密码配置混用。
npm公共授权源
需要从 npm 公共源安装或向其发布时,将对应 scope 的 registry 改为:
registry=https://registry.npmjs.org/
@94ai:registry=https://registry.npmjs.org/
@94ai-plus:registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}由公司管理员提供 NPM_AUTH_TOKEN,也可以加入公司在npm上的Organizations成为Member后手动生成Access Tokens,可以生成时开启 Bypass two-factor authentication (2FA) 来满足 npm 的 2FA/Token 策略。
Yarn 4 配置
Yarn 4 不读取 .npmrc 中的认证配置,使用 .yarnrc.yml。Yarn 4 同时支持 npmAuthToken 和 npmAuthIdent 这两个字段,用于不同认证方式:
npmAuthToken:Token 认证,例如 npm Access Token。npmAuthIdent:用户名+密码认证,支持username:password或该完整字符串的 Base64 编码。
用户名+密码认证参考如下配置:
npmScopes:
94ai-plus:
npmRegistryServer: "https://packages.aliyun.com/644f755a97d94d909e43534c/npm/npm-registry/"
npmAlwaysAuth: true
npmAuthIdent: "${NPM_PRIVATE_AUTH_IDENT}"NPM_PRIVATE_AUTH_IDENT 为完整的 username:明文密码 的 Base64 编码,不等于 .npmrc 的 _password 值。上述为手动配置参考;本仓库会自动根据 NPM_PRIVATE_USERNAME、NPM_PRIVATE_PASSWORD_BASE64 在内存中生成该值,无需手工填写,不输出到日志或写入仓库。
Token 认证参考如下配置:
npmScopes:
94ai-plus:
npmRegistryServer: "https://registry.npmjs.org/"
npmAlwaysAuth: true
npmAuthToken: "${NPM_AUTH_TOKEN}"可以在 PowerShell 中临时设置授权,不修改受版本控制的 Yarn 配置:
$env:NPM_REGISTRY_URL = 'https://registry.npmjs.org/'
# NPM_AUTH_TOKEN 通过本机环境或 CI Secret 注入,不把真实值写进脚本。
yarn install --immutable在本仓库根目录的 .env.local 填写:
NPM_REGISTRY_URL=https://packages.aliyun.com/644f755a97d94d909e43534c/npm/npm-registry/
NPM_PRIVATE_USERNAME=
NPM_PRIVATE_PASSWORD_BASE64=随后直接执行 yarn install --immutable 即可自动加载,无需额外的 Node 命令;终端/CI 同名变量优先。私库用户名和 Base64 密码齐全时,安装与发布优先使用该认证,不要求 NPM_AUTH_TOKEN;切换到 npm 公共源发布仍需 Token。.env.local 已被 .gitignore 忽略;直接执行 npm 命令不会自动读取此文件。其他项目使用上述 Yarn 配置示例时,仍需自行注入认证环境变量。
安装依赖
yarn add @94ai-plus/common-ui @94ai-plus/nf-theme-chalk vue@3.5.44 element-plus@2.14.7也可使用 npm:
npm install @94ai-plus/common-ui @94ai-plus/nf-theme-chalk vue@3.5.44 element-plus@2.14.7