You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

31 lines
1020 B

// 修复 is-generator-function 的 Node.js 22 兼容性问题
const fs = require('fs');
const path = require('path');
const indexPath = path.join(__dirname, '../node_modules/.pnpm/is-generator-function@1.1.2/node_modules/is-generator-function/index.js');
if (fs.existsSync(indexPath)) {
let content = fs.readFileSync(indexPath, 'utf8');
// 替换有问题的 getGeneratorFunction 调用
const fixedContent = content.replace(
/var GeneratorFunction = getGeneratorFunction\(\);/g,
`var GeneratorFunction;
try {
GeneratorFunction = getGeneratorFunction();
} catch (e) {
// Node.js 22 兼容性修复
try {
GeneratorFunction = (function*() {}).constructor;
} catch (e2) {
GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
}
}`
);
fs.writeFileSync(indexPath, fixedContent, 'utf8');
console.log('✅ 已修复 is-generator-function 兼容性问题');
} else {
console.log('⚠️ 未找到 is-generator-function 文件,可能需要先安装依赖');
}