BitBucket 管道未能构建生产 Angular 代码(暂存和本地机器工作)
BitBucket Pipelines failing to build production Angular code (staging and local machine working)
我正在使用 BitBucket Pipelines 尝试自动部署暂存和生产编译代码。暂存工作正常,生产在我的本地服务器上工作正常,但在管道上却不行。失败日志如下,我不知道为什么会失败:
"build:prod": "ng build --prod"
+ npm run build:prod
> mobile-app@1.1.2 build:prod /opt/atlassian/pipelines/agent/build
> ng build --prod
Browserslist: caniuse-lite is outdated. Please run next command `npm update`
<--- Last few GCs --->
[67:0x3002f10] 220826 ms: Mark-sweep 2014.9 (2069.4) -> 2004.8 (2071.6) MB, 908.6 / 0.1 ms (average mu = 0.172, current mu = 0.096) allocation failure scavenge might not succeed
[67:0x3002f10] 222095 ms: Mark-sweep 2016.7 (2071.6) -> 2011.3 (2074.4) MB, 1215.6 / 0.1 ms (average mu = 0.110, current mu = 0.042) allocation failure scavenge might not succeed
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x140a8f9]
Security context: 0x325873d008d1 <JSObject>
1: join [0x325873d155f9](this=0x1de208ef3a99 <JSArray[11]>,0x20ca5d5b37a1 <String[#1]: />)
2: computeSourceURL [0x1d3973de0b1] [/opt/atlassian/pipelines/agent/build/node_modules/webpack-sources/node_modules/source-map/lib/util.js:~441] [pc=0x873448f2a77](this=0x0e122b985d01 <Object map = 0x3ff287ea2f39>,0x05b8fbf40731 <String[#0]: >,0x0513ea418d71 <String...
1: 0xa18150 node::Abort() [ng build --prod]
2: 0xa1855c node::OnFatalError(char const*, char const*) [ng build --prod]
3: 0xb9715e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [ng build --prod]
4: 0xb974d9 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [ng build --prod]
5: 0xd54755 [ng build --prod]
6: 0xd54de6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [ng build --prod]
7: 0xd616a5 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [ng build --prod]
8: 0xd62555 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [ng build --prod]
9: 0xd6500c v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [ng build --prod]
10: 0xd2ba2b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [ng build --prod]
11: 0x106dffe v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [ng build --prod]
12: 0x140a8f9 [ng build --prod]
Aborted (core dumped)
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! mobile-app@1.1.2 build:prod: `ng build --prod`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the mobile-app@1.1.2 build:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-01-30T19_46_54_147Z-debug.log
这是我的bitbucket-pipelines.yml
,如果有帮助:
pipelines:
custom:
production:
- step:
name: Build an app
image: node:12.20.1
deployment: production
caches:
- node
script:
- npm install
- npm run build:prod
artifacts:
- dist/**
- step:
name: Deploy to droplet
script:
- rsync -rzO dist/ $SSH_USER@$SSH_SERVER:/home/$WEBSITE/$URL/ --exclude=bitbucket-pipelines.yml
我也试过(每次尝试一行),都失败了:
- node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod
- size: 2x
- ng build --prod
已将我的 bitbucket-pipelines.yml
更新到此,目前可以使用:
pipelines:
custom:
production:
- step:
name: Build an app
image: node:12.20.1
deployment: production
caches:
- node
size: 2x
script:
- npm install
- export NODE_OPTIONS=--max-old-space-size=6144
- npm run build:prod
artifacts:
- dist/**
- step:
name: Deploy to droplet
script:
- rsync -rzO dist/ $SSH_USER@$SSH_SERVER:/home/$WEBSITE/$URL/ --exclude=bitbucket-pipelines.yml
该应用程序比较大,所以现在我希望它能正常工作。一旦应用程序增长得更多,如果这也因为内存问题而开始失败,我不知道该怎么办。
对我们来说,将 node version
更改为 14.XX.xx
在 bitbucket 管道中确实有效
- step:
image: node:14.16.0
我正在使用 BitBucket Pipelines 尝试自动部署暂存和生产编译代码。暂存工作正常,生产在我的本地服务器上工作正常,但在管道上却不行。失败日志如下,我不知道为什么会失败:
"build:prod": "ng build --prod"
+ npm run build:prod
> mobile-app@1.1.2 build:prod /opt/atlassian/pipelines/agent/build
> ng build --prod
Browserslist: caniuse-lite is outdated. Please run next command `npm update`
<--- Last few GCs --->
[67:0x3002f10] 220826 ms: Mark-sweep 2014.9 (2069.4) -> 2004.8 (2071.6) MB, 908.6 / 0.1 ms (average mu = 0.172, current mu = 0.096) allocation failure scavenge might not succeed
[67:0x3002f10] 222095 ms: Mark-sweep 2016.7 (2071.6) -> 2011.3 (2074.4) MB, 1215.6 / 0.1 ms (average mu = 0.110, current mu = 0.042) allocation failure scavenge might not succeed
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x140a8f9]
Security context: 0x325873d008d1 <JSObject>
1: join [0x325873d155f9](this=0x1de208ef3a99 <JSArray[11]>,0x20ca5d5b37a1 <String[#1]: />)
2: computeSourceURL [0x1d3973de0b1] [/opt/atlassian/pipelines/agent/build/node_modules/webpack-sources/node_modules/source-map/lib/util.js:~441] [pc=0x873448f2a77](this=0x0e122b985d01 <Object map = 0x3ff287ea2f39>,0x05b8fbf40731 <String[#0]: >,0x0513ea418d71 <String...
1: 0xa18150 node::Abort() [ng build --prod]
2: 0xa1855c node::OnFatalError(char const*, char const*) [ng build --prod]
3: 0xb9715e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [ng build --prod]
4: 0xb974d9 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [ng build --prod]
5: 0xd54755 [ng build --prod]
6: 0xd54de6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [ng build --prod]
7: 0xd616a5 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [ng build --prod]
8: 0xd62555 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [ng build --prod]
9: 0xd6500c v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [ng build --prod]
10: 0xd2ba2b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [ng build --prod]
11: 0x106dffe v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [ng build --prod]
12: 0x140a8f9 [ng build --prod]
Aborted (core dumped)
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! mobile-app@1.1.2 build:prod: `ng build --prod`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the mobile-app@1.1.2 build:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-01-30T19_46_54_147Z-debug.log
这是我的bitbucket-pipelines.yml
,如果有帮助:
pipelines:
custom:
production:
- step:
name: Build an app
image: node:12.20.1
deployment: production
caches:
- node
script:
- npm install
- npm run build:prod
artifacts:
- dist/**
- step:
name: Deploy to droplet
script:
- rsync -rzO dist/ $SSH_USER@$SSH_SERVER:/home/$WEBSITE/$URL/ --exclude=bitbucket-pipelines.yml
我也试过(每次尝试一行),都失败了:
- node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod
- size: 2x
- ng build --prod
已将我的 bitbucket-pipelines.yml
更新到此,目前可以使用:
pipelines:
custom:
production:
- step:
name: Build an app
image: node:12.20.1
deployment: production
caches:
- node
size: 2x
script:
- npm install
- export NODE_OPTIONS=--max-old-space-size=6144
- npm run build:prod
artifacts:
- dist/**
- step:
name: Deploy to droplet
script:
- rsync -rzO dist/ $SSH_USER@$SSH_SERVER:/home/$WEBSITE/$URL/ --exclude=bitbucket-pipelines.yml
该应用程序比较大,所以现在我希望它能正常工作。一旦应用程序增长得更多,如果这也因为内存问题而开始失败,我不知道该怎么办。
对我们来说,将 node version
更改为 14.XX.xx
在 bitbucket 管道中确实有效
- step:
image: node:14.16.0