我正在处理一个角度为8的项目,并尝试将其构建为生产环境,但是每次运行build命令时,它都会显示致命错误:无效的标记紧凑接近堆限制分配失败-JavaScript堆内存不足 。我无法找出错误,因为应用程序在开发模式下可以正常工作。
npm日志文件:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node',
1 verbose cli '/usr/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build:client-and-server-bundles' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild:client-and-server-bundles',
4 verbose run-script 'build:client-and-server-bundles',
4 verbose run-script 'postbuild:client-and-server-bundles' ]
5 info lifecycle [email protected]~prebuild:client-and-server-bundles: [email protected]
6 info lifecycle [email protected]~build:client-and-server-bundles: [email protected]
7 verbose lifecycle [email protected]~build:client-and-server-bundles: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build:client-and-server-bundles: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ekodev/angular_b2b/node_modules/.bin:/usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ekodev/angular_b2b/node_modules/.bin:/home/ekodev/bin:/home/ekodev/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle [email protected]~build:client-and-server-bundles: CWD: /home/ekodev/angular_b2b
10 silly lifecycle [email protected]~build:client-and-server-bundles: Args: [ '-c',
10 silly lifecycle 'node --max_old_space_size=32276 node_modules/@angular/cli/bin/ng build --prod --aot --output-hashing=all && ng run angularproject:server:production' ]
11 silly lifecycle [email protected]~build:client-and-server-bundles: Returned: code: 134 signal: null
12 info lifecycle [email protected]~build:client-and-server-bundles: Failed to exec build:client-and-server-bundles script
13 verbose stack Error: [email protected] build:client-and-server-bundles: `node --max_old_space_size=32276 node_modules/@angular/cli/bin/ng build --prod --aot --output-hashing=all && ng run angularproject:server:production`
13 verbose stack Exit status 134
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:198:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/ekodev/angular_b2b
16 verbose Linux 4.4.0-169-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build:client-and-server-bundles"
18 verbose node v10.19.0
19 verbose npm v6.13.4
20 error code ELIFECYCLE
21 error errno 134
22 error [email protected] build:client-and-server-bundles: `node --max_old_space_size=32276 node_modules/@angular/cli/bin/ng build --prod --aot --output-hashing=all && ng run angularproject:server:production`
22 error Exit status 134
23 error Failed at the [email protected] build:client-and-server-bundles script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 134, true ]
我尝试搜索问题,但找不到任何东西。我真的需要尽快修复此问题。请帮忙。谢谢
尝试在生产服务器上触发此命令以第一次创建构建版本
node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod