我已经尝试过:
- 在VS代码的bash提示中执行
export NODE_OPTIONS="--max-old-space-size=4096"
- 在系统bash提示中执行
export NODE_OPTIONS="--max-old-space-size=4096"
- 将其添加到我用户的
.bashrc
文件中并重新启动 - 针对项目安装和运行增加内存限制
似乎没有任何作用。如果项目超过一定尺寸,则使用Mac上使用VS代码进行调试似乎是不可能的。我总是最终得到Ineffective mark-compacts near heap limit Allocation failed
。它可以从bash运行,但不从VS代码运行。
有人有任何想法吗?
我找到了一种使此工作的方法,我想我会在这里录制它是为了使他人受益。
我不得不用黑客修补插件,这肯定可以更优雅(我将尝试实现并提交PR(。
在nativescriptcli.ts中,我修改了以下方法,以将NODE_OPTIONS
环境变量添加到Node
的每个产卵中:
public executeSync(args: string[], cwd: string): string {
args.unshift('--analyticsClient', 'VSCode');
const command: string = `${this._path} ${args.join(' ')}`;
let env = process.env;
env["NODE_OPTIONS"] = "--max-old-space-size=4096";
this._logger.log(`[NativeScriptCli] execute: ${command}`);
return execSync(command, { encoding: 'utf8', cwd, shell: this._shellPath, env: env }).toString().trim();
}
public execute(args: string[], cwd: string): ChildProcess {
args.unshift('--analyticsClient', 'VSCode');
const command: string = `${this._path} ${args.join(' ')}`;
this._logger.log(`[NativeScriptCli] execute: ${command}`);
let env = process.env;
env["NODE_OPTIONS"] = "--max-old-space-size=4096";
const options = { cwd, shell: this._shellPath, env: env };
const child: ChildProcess = spawn(this._path, args, options);
child.stdout.setEncoding('utf8');
child.stderr.setEncoding('utf8');
return child;
}
在我的Mac上安装此黑客版本后,该应用程序现在成功地构建了VS Code
。