修复 esm 依赖查询路径

This commit is contained in:
whyour
2026-06-13 21:04:17 +08:00
parent 949d956aef
commit 5f2d5bb24a
2 changed files with 46 additions and 0 deletions
+5
View File
@@ -4,6 +4,11 @@ const path = require('path');
const client = require('./client.js');
require(`./env.js`);
// 注册 ESM loader,使全局安装的包也可通过 import 导入
try {
Module.register(new URL('esm-loader.mjs', `file://${__dirname}/`).href);
} catch (_) {}
function preferGlobalNodeModules() {
const { QL_NODE_GLOBAL_PATH } = process.env;
if (!QL_NODE_GLOBAL_PATH || Module._qlGlobalPathPatched) {