Unverified 提交 dfe6da06 authored 作者: Bryan's avatar Bryan 提交者: GitHub

fix: add Node.js version check for capacitor cmds (#801)

Resolves #787. Prevents crashes when running capacitor commands on a system with an incompatible (older) Node.js version. --------- Co-authored-by: 's avatarWill Chen <willchen90@gmail.com>
上级 676d07e9
...@@ -40,6 +40,20 @@ export function registerCapacitorHandlers() { ...@@ -40,6 +40,20 @@ export function registerCapacitorHandlers() {
async (_, { appId }: { appId: number }): Promise<boolean> => { async (_, { appId }: { appId: number }): Promise<boolean> => {
const app = await getApp(appId); const app = await getApp(appId);
const appPath = getDyadAppPath(app.path); const appPath = getDyadAppPath(app.path);
// check for the required Node.js version before running any commands
const currentNodeVersion = process.version;
const majorVersion = parseInt(
currentNodeVersion.slice(1).split(".")[0],
10,
);
if (majorVersion < 20) {
// version is too old? stop and throw a clear error
throw new Error(
`Capacitor requires Node.js v20 or higher, but you are using ${currentNodeVersion}. Please upgrade your Node.js and try again.`,
);
}
return isCapacitorInstalled(appPath); return isCapacitorInstalled(appPath);
}, },
); );
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论