module_exist
用于检测包是否安装
源码
查看源码
module_exist/index.ts源码
ts
export function module_exist(name: string): boolean {
try {
require.resolve(name);
} catch (err: any) {
console.log("err ", err.code);
if (err.code === "MODULE_NOT_FOUND") {
return false;
}
}
return true;
}
export function module_exist(name: string): boolean {
try {
require.resolve(name);
} catch (err: any) {
console.log("err ", err.code);
if (err.code === "MODULE_NOT_FOUND") {
return false;
}
}
return true;
}