当我使用Ionic serve命令运行Ionic 3项目时,我会得到这个错误:
当前回答
我没有使用ng build,而是在终端中执行以下命令来修复这个问题。
node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod
那就发球吧。
这就是我的终端机
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS D:\ProjectPath\Project1> node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod
其他回答
当我在Visual Studio Code中执行以下语句时,我得到了相同的错误消息。但是当我在Windows命令行中执行相同的东西时,我可以成功地构建。
npm install -g increase-memory-limit
increase-memory-limit
set NODE_OPTIONS=--max_old_space_size=4096
ng build -c deploy --build-optimizer --aot --prod --sourceMap
在项目文件夹中运行此命令。使用服务而不是构建
node --max_old_space_size=8000 node_modules/@angular/cli/bin/ng serve --prod --port=4202
对我来说,当我在React项目中使用一个大的构建目录运行ESLint和Prettier时遇到了这个问题。取出后,一切都正常了。
我想这是因为在构建目录中有太多的文件。
由于某些原因,之前所有的答案对我都不起作用。我做了以下来解决我的问题:
我必须首先删除node_modules文件夹 在我的电脑上重新安装Node.js 然后安装NPM
我在Angular上也遇到了同样的问题。然后我写了
"serve": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng serve"
要打包的脚本。Json脚本,为我解决了这个问题。
并运行project this命令:
npm run serve