Canary 版本
Docusaurus 提供 Canary 版本。
It permits you to test new unreleased features as soon as the pull requests are merged.
It is a good way to give feedback to maintainers, ensuring the newly implemented feature works as intended.
实际上,在生产环境中使用 Canary 版本并不存在风险。
Canary 版本通过了所有的自动化测试,Docusaurus 网站自己也在生产环境中使用此版本。
The canary version shown below may not be up-to-date. Please go to the npm page to find the actual version name.
Canary npm 版本标签
For any code-related commit on main, the continuous integration will publish a canary release under the @canary npm dist tag. 这一般需要 10 分钟左右。
You can see on npm the current dist tags:
latest: stable releases (Current: 3.10.2)canary: canary releases (例如:0.0.0-4922)
Make sure to use the latest canary release and check the publication date (sometimes the publish process fails).
Canary versions follow the naming convention 0.0.0-commitNumber.
使用 Canary 版本
Take the latest version published under the canary npm dist tag (例如:0.0.0-4922).
Use it for all the @docusaurus/* dependencies in your package.json:
- "@docusaurus/core": "^3.10.2",
- "@docusaurus/preset-classic": "^3.10.2",
+ "@docusaurus/core": "0.0.0-4922",
+ "@docusaurus/preset-classic": "0.0.0-4922",
然后重新安装依赖,再启动你的网站:
- npm
- Yarn
- pnpm
- Bun
npm install
npm start
yarn install
yarn start
pnpm install
pnpm start
bun install
bun start
You can also upgrade the @docusaurus/* packages with command line:
- npm
- Yarn
- pnpm
- Bun
npm install --save-exact @docusaurus/core@canary @docusaurus/preset-classic@canary
yarn add --exact @docusaurus/core@canary @docusaurus/preset-classic@canary
pnpm add --save-exact @docusaurus/core@canary @docusaurus/preset-classic@canary
bun add --exact @docusaurus/core@canary @docusaurus/preset-classic@canary
Make sure to include all the @docusaurus/* packages.
For canary releases, prefer using an exact version instead of a semver range (avoid the ^ prefix).
Some package managers have security options enabled by default to mitigate supply chain attacks, notably requiring npm packages to reach a minimum age.
To ensure the most recent canary release can install successfully, try the following options env variables:
# npm
# if it doesn't work, try "npm_config_min_release_age=0"
# see https://github.com/facebook/docusaurus/pull/12437
npm_config_min_release_age_exclude='create-docusaurus,@docusaurus/*'
# pnpm
PNPM_CONFIG_MINIMUM_RELEASE_AGE_EXCLUDE='["create-docusaurus","@docusaurus/*"]'
# Yarn Berry
yarn config set --json npmPreapprovedPackages '["create-docusaurus","@docusaurus/*"]'
Creating a new canary website
Here's a full example script to initialize a new Docusaurus site with our most recent canary release:
PNPM_CONFIG_MINIMUM_RELEASE_AGE_EXCLUDE='["create-docusaurus","@docusaurus/*"]' pnpm dlx create-docusaurus@canary my-canary-website classic --typescript
cd my-canary-website
pnpm config set --location=project --json minimumReleaseAgeExclude '["create-docusaurus","@docusaurus/*"]'
pnpm config set --location=project --json allowBuilds '{"@swc/core":false,"core-js":false}'
pnpm install
pnpm build