简体   繁体   English

纱线安装和构建消耗 100% CPU 和 memory 95%

[英]yarn install and build consumes 100% CPU and memory 95%

I am working on Electron, Angular 8, Nodejs based project.我正在研究 Electron、Angular 8、基于 Nodejs 的项目。 Whenever I use the following command, my system consumes 100% CPU utilization and 95% memory, and the system freezes for 5 to 7 minutes.每当我使用以下命令时,我的系统会消耗 100% 的 CPU 利用率和 95% 的 memory,并且系统会冻结 5 到 7 分钟。 I am using yarn instead of npm as suggested by our UI architects.正如我们的 UI 架构师所建议的那样,我正在使用 yarn 而不是 npm。

I use the following command.我使用以下命令。

yarn install && yarn build

I am using Windows 10 with 16 GB RAM.我正在使用具有 16 GB RAM 的 Windows 10。 It is a common problem for other team members also.这也是其他团队成员的常见问题。 As per package.json , the command for yarn build is根据package.json ,纱线构建的命令是

"build": "rimraf dist && webpack --config config/webpack.dev.js",

I provide below the code for webpack.dev.js我在下面提供webpack.dev.js的代码

const webpackMerge = require('webpack-merge');
const commonConfig = require('./webpack.common.js');

module.exports = webpackMerge(commonConfig, {
    mode: 'development',
    devtool: 'inline-source-map',
});

Currently, the size of node_modules directory is 1.5 GB.目前, node_modules目录的大小为 1.5 GB。 I want to know whether it is the expected behavior in case NodeJS or yarn-based project?我想知道这是否是 NodeJS 或基于纱线的项目的预期行为? I have very large applications in java but when I build using Maven or Gradle, I do not see this kind of behavior.我在 java 中有非常大的应用程序,但是当我使用 Maven 或 Gradle 构建时,我看不到这种行为。 Please suggest me whether it can be improved.请建议我是否可以改进。

I have also gone through the following StackOverflow link and could not get a proper answer.我也浏览了以下 StackOverflow 链接,但无法得到正确答案。 yarn install consumes all memory on TeamCity and Jenkins yarn install 消耗 TeamCity 和 Jenkins 上的所有 memory

This looks like a webpack problem.这看起来像webpack问题。 Have you run into this github issue ?你遇到过这个 github 问题吗?

The response boils down to this:回应归结为:

What is happening under the hood: At this moment we use antwar, a Static site generator created by one of the original contributors to this repo, it uses Workers which use all availables cores in your system, basically occupying the entire CPU capacity.幕后发生的事情:目前我们使用 antwar,这是一个 Static 站点生成器,由该 repo 的原始贡献者之一创建,它使用使用系统中所有可用内核的 Workers,基本上占据了整个 CPU 容量。

There is an option to limit cores, but the link is not working and I'm currently searching for it in the official webpack github.有一个限制内核的选项,但链接不起作用,我目前正在官方 webpack github 中搜索它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM