最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

如何在BitcriptWebpack的Bitbucket管道中增加NodeJS堆(

IT培训 admin 4浏览 0评论

如何在Bitcript / Webpack的Bitbucket管道中增加NodeJS堆(

我在无服务器/ TypeScript项目的webpack打包步骤中遇到了内存问题。

我努力了:

  • '增加内存限制'​​npm包无济于事
  • 从npm运行脚本调用以下命令
  • 直接通过bitbucket-pipelines.yml调用以下命令。 node --max-old-space-size=4096 ./node_modules/.bin/serverless deploy

它在本地使用此命令工作正常,但在Bitbucket管道中,我得到以下输出:

    Serverless: Bundling with Webpack...

    internal/child_process.js:323
        throw errnoException(err, 'spawn');
        ^
    Error: spawn ENOMEM
        at _errnoException (util.js:1022:11)
        at ChildProcess.spawn (internal/child_process.js:323:11)
        at exports.spawn (child_process.js:502:9)
        at Object.exports.fork (child_process.js:103:10)
        at fork (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/fork.js:17:36)
        at Farm.startChild (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:106:16)
        at Farm.processQueue (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:279:10)
        at Farm.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:97:21)
        at ontimeout (timers.js:475:11)
        at tryOnTimeout (timers.js:310:5)
        at Timer.listOnTimeout (timers.js:270:5)
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] deploy: `node --max-old-space-size=4096 ./node_modules/.bin/serverless deploy "--stage"    "feattsify" "--region" "us-east-1"`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the [email protected] deploy 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/2019-02-07T22_37_25_150Z-debug.log

我已经做了很多谷歌搜索并在这里搜索,试图找出Bitbucket是否有某种环境。您可以为运行时args等设置的变量,但似乎找不到任何与上述NPM包无关的内容。

回答如下:

前段时间我在一些Jenkins构建任务中遇到了类似的问题。您可以使用NODE_OPTION环境变量来解决它:

NODE_OPTIONS=--max_old_space_size=4096

从您的错误堆栈跟踪,看起来新的节点进程正在产生。如果您可以设置此环境变量,则节点将使用它将参数传递给任何新进程,以及此处生成内存不足的衍生进程。

https://nodejs/dist/latest-v8.x/docs/api/cli.html#cli_node_options_options

如何在Bitcript / Webpack的Bitbucket管道中增加NodeJS堆(

我在无服务器/ TypeScript项目的webpack打包步骤中遇到了内存问题。

我努力了:

  • '增加内存限制'​​npm包无济于事
  • 从npm运行脚本调用以下命令
  • 直接通过bitbucket-pipelines.yml调用以下命令。 node --max-old-space-size=4096 ./node_modules/.bin/serverless deploy

它在本地使用此命令工作正常,但在Bitbucket管道中,我得到以下输出:

    Serverless: Bundling with Webpack...

    internal/child_process.js:323
        throw errnoException(err, 'spawn');
        ^
    Error: spawn ENOMEM
        at _errnoException (util.js:1022:11)
        at ChildProcess.spawn (internal/child_process.js:323:11)
        at exports.spawn (child_process.js:502:9)
        at Object.exports.fork (child_process.js:103:10)
        at fork (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/fork.js:17:36)
        at Farm.startChild (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:106:16)
        at Farm.processQueue (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:279:10)
        at Farm.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:97:21)
        at ontimeout (timers.js:475:11)
        at tryOnTimeout (timers.js:310:5)
        at Timer.listOnTimeout (timers.js:270:5)
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] deploy: `node --max-old-space-size=4096 ./node_modules/.bin/serverless deploy "--stage"    "feattsify" "--region" "us-east-1"`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the [email protected] deploy 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/2019-02-07T22_37_25_150Z-debug.log

我已经做了很多谷歌搜索并在这里搜索,试图找出Bitbucket是否有某种环境。您可以为运行时args等设置的变量,但似乎找不到任何与上述NPM包无关的内容。

回答如下:

前段时间我在一些Jenkins构建任务中遇到了类似的问题。您可以使用NODE_OPTION环境变量来解决它:

NODE_OPTIONS=--max_old_space_size=4096

从您的错误堆栈跟踪,看起来新的节点进程正在产生。如果您可以设置此环境变量,则节点将使用它将参数传递给任何新进程,以及此处生成内存不足的衍生进程。

https://nodejs/dist/latest-v8.x/docs/api/cli.html#cli_node_options_options

发布评论

评论列表 (0)

  1. 暂无评论