sj_*_*959 7 javascript node.js npm vue.js
我已经在本地克隆了一个包含 Vue 项目的 git 存储库git clone
。然后我跑去npm install
安装依赖项并得到node_modules
文件夹。
运行时npm run serve
出现以下错误:
[11920:03BEA178] 321556 ms: Scavenge (reduce) 429.1 (464.7) -> 429.1 (464.7) MB, 37.7 / 17.8 ms (average mu = 0.980, current mu = 0.932) allocation failure
[11920:03BEA178] 321643 ms: Scavenge (reduce) 429.7 (465.2) -> 429.7 (465.2) MB, 61.2 / 0.9 ms (average mu = 0.980, current mu = 0.932) allocation failure
[11920:03BEA178] 321765 ms: Scavenge (reduce) 432.2 (467.3) -> 432.2 (467.3) MB, 22.1 / 0.0 ms (average mu = 0.980, current mu = 0.932) allocation failure
<--- JS stacktrace --->
FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! vue-argon-dashboard-pro@1.1.0 serve: `vue-cli-service serve --open`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the vue-argon-dashboard-pro@1.1.0 serve 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! C:\Users\sagar\AppData\Roaming\npm-cache\_logs\2020-12-10T09_32_00_595Z-debug.log
Run Code Online (Sandbox Code Playgroud)
此外,我的node_modules
文件夹大小约为 8GB。我在带有 2GB RAM 的敞篷车上运行它。
我设法克服此错误的方法是关闭 TerserPlugin 的最小化,如下webpack.config.js
所示:
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
optimization: {
minimize: false,
minimizer: [new TerserPlugin()],
},
};
Run Code Online (Sandbox Code Playgroud)
这可能并不适合所有人,因为在我看来,当 RAM 不足时就会出现此错误。当我在具有 4GB RAM 和更多硬盘空间的笔记本电脑上运行该应用程序时,我无需进行设置minimize
。false
您可以在开发阶段设置minimize
为,并在应用程序准备好生产时将其设置回。false
true