Our normal YARN serve/build can cause errors if the project becomes too large, logical, and file heavy

Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Copy the code

The node memory limit was exceeded when it was compiled

{"serve": "node --max_old_space_size=8000./node_modules/@angular/cli/bin/ng serve"}Copy the code
Yarn add increase-memory-limit increase-memory-limitCopy the code

Baidu to the general method is the above two points, but I have used, and finally fruitless, the same error. I even used this method as described on the Internet

cross-env LIMIT=4096000 increase-memory-limit
Copy the code

This is even more outrageous

Finally, I found out the cause of my project error by comparing the code changes before and after

The solution

vue.config.js

module.exports = {
  lintOnSave: false
 }
Copy the code

It doesn’t seem to matter, but because my project recently added a lot of ESlint validation rules (a lot of rules), Node reported errors when packing and compiling.

lintOnSave

Sets whether esLint validation is enabled every time code is saved in the development environment. Default: true,

False: disables detection for each save true: enables detection for each save, and the effect is the same as warning Warning: Enables detection for each save, and Lint errors will be displayed on the console command line and compilation will not fail. Error: Enable checks every save, lint errors will be displayed on the browser page, and compilation will fail. Default: with the errorCopy the code

conclusion

So the reason I’m running out of memory is because of a lot of ESLint rule validation. Since the project had lint-staged code configured before submission, and this was already done with vscode’s eslint plug-in, I disabled this configuration. Also be solved this problem, the children’s shoes that has similar problem can refer to.

The above is not very detailed, as the record of the pit.