版本不匹配
确保你安装的所有 Remotion 包(remotion、@remotion/player、@remotion/cli 等)版本一致是很重要的。如果版本不同,包可能无法正确相互通信,这可能引入细微的错误,甚至导致完全失效。
🌐 It is important that all Remotion packages you install (remotion, @remotion/player, @remotion/cli, etc.) have the same version installed. If the versions differ, the packages might not be able to correctly communicate with each other which can introduce subtle bugs or even complete breakage.
^ 字符可能令人困惑
🌐 ^ character can be confusing
以下 package.json 不能确保所有 Remotion 版本相同:
🌐 The following package.json does not ensure that all Remotion versions are the same:
package.json{ "dependencies": { "remotion": "^2.6.12", "@remotion/player": "^2.6.12", "@remotion/gif": "^2.6.12" } }
然而,以下清单确实:
🌐 however the following manifest does:
package.json{ "dependencies": { "remotion": "2.6.12", "@remotion/player": "2.6.12", "@remotion/gif": "2.6.12" } }
如果这些包是分阶段安装而不是一次性安装,这一点尤其正确。移除 ^ 字符是确保所有 Remotion 包版本相同的好方法。
🌐 This is especially true if the packages are installed over time and not all at once. Removing the ^ character is a good way to ensure all Remotion packages have the same version.
依赖于 Remotion 的软件包
🌐 Packages that depend on Remotion
如果你创建一个 Remotion 库并将其发布到 npm,请将 Remotion 设为 peerDependency 和 devDependency 而不是依赖:
🌐 If you make a Remotion library and put it on npm, make Remotion a peerDependency and devDependency instead of a dependency:
package.json{ "name": "my-remotion-library", "peerDependencies": { "remotion": "*" }, "devDependencies": { "remotion": "^2.6.11" } }
这将确保当你把 my-remotion-library 安装到你的 Remotion 项目中时,不会引入重复的 Remotion:
🌐 This will make sure that when you then install my-remotion-library into your Remotion project, that no duplicates of Remotion will be introduced:
{
"dependencies": {
// No version mismatch will be introduced because `remotion`
// is not a direct dependency of `my-remotion-library`
"remotion": "2.7.0",
"my-remotion-library": "1.0.0"
}
}检查已安装了哪些版本
🌐 Checking which versions have been installed
仅仅因为 package.json 中的版本是 ^2.6.11 并不意味着版本 2.6.11 已经安装。使用命令:
🌐 Just because the version in the package.json is ^2.6.11 does not mean that the version 2.6.11 got installed. Use the command:
npx remotion versions查看你的项目包含了哪些软件包及其版本。
🌐 to see which packages and versions your project contains.