我正在开发基于 Electron、Angular 8、Nodejs 的项目。每当我使用以下命令时,我的系统都会消耗 100% 的 CPU 利用率和 95% 的内存,并且系统会卡住 5 到 7 分钟。按照我们的 UI 架构师的建议,我正在使用 yarn 而不是 npm。
我使用以下命令。
yarn install && yarn build
我使用的是具有 16 GB RAM 的 Windows 10。对于其他团队成员来说,这也是一个常见问题。
根据package.json
,yarn构建的命令是
"build": "rimraf dist && webpack --config config/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',
});
目前,node_modules
目录的大小为1.5 GB。
我想知道这是否是 NodeJS 或基于 yarn 的项目的预期行为?我在 java 中有非常大的应用程序,但是当我使用 Maven 或 Gradle 构建时,我没有看到这种行为。
请建议我是否可以改进。
我还浏览了以下 StackOverflow 链接,但无法得到正确的答案。 yarn install consumes all memory on TeamCity and Jenkins
最佳答案
这看起来像是一个 webpack
问题。你有没有遇到this github issue ?
响应归结为:
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.
有一个限制核心的选项,但链接不起作用,我目前正在官方 webpack github 中搜索它。
关于java - yarn 安装和构建消耗 100% CPU 和内存 95%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58888568/