我有一个使用express.js(typescript)编写的项目,其中包含以下命令添加到package.json文件中:
"scripts": {
"start": "npm run build && npm run watch",
"build": "npm run build-ts && npm run tslint",
"serve": "nodemon dist/server.js",
"watch": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-ts\" \"npm run serve\"",
"test": "jest --forceExit",
"build-ts": "tsc",
"watch-ts": "tsc -w",
"tslint": "tslint -c tslint.json -p tsconfig.json",
"debug": "npm run build && npm run watch-debug",
"serve-debug": "nodemon --inspect dist/server.js",
"watch-debug": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-ts\" \"npm run serve-debug\"",
"angular-build": "cd app && ng build --prod --output-path=../dist/app/ --deploy-url= --no-progress --aot true"
},
我知道增加堆内存大小的命令是--max-old-space-size,但我不知道该把它放在哪里...
我看到的所有示例都是这样的。
node --max-old-space-size=4096 myapp.js
但我不是这样运行我的应用程序的... 我只运行 "npm start"
我使用这段代码来检查当前堆大小
let v8 = require("v8");
let totalHeapSizeInGB = (((v8.getHeapStatistics().total_available_size) / 1024 / 1024 / 1024).toFixed(2));
console.log(`*******************************************`);
console.log(`Total Heap Size ~${totalHeapSizeInGB}GB`);
console.log(`*******************************************`);
npm start
runs thestart
script, which runsserve
, which then runsserve
. Change serve tonodemon dist/server.js --max-old-space-size=4096
- Phix1.39GB
的结果,使用标志后我得到了0.02GB
的结果,所以它正在做某些事情。 - Phix