I've encountered this scary-looking error on multiple occasions when my application ran out of memory.
In this short article, I'll first give you a solution that you can use to fix this issue quickly.
After that, in case you want to know more about it, I'll explain what the causes of this error can be and how to prevent it from happening in the future.
The fastest way of solving this issue is by increasing the memory limit of Node. Starting from Node.js v8, you can set the limit in MB with the
--max-old-space-size flag like this:
node --max-old-space-size=4096 index.js
4096 translates to 4 GB of memory. You can set the limit to whatever you like, but make sure you don't use all the available memory, or otherwise, your system might crash.
As an alternative to this, you can also set the flag in an environment variable like this:
NODE_OPTIONS="--max-old-space-size=4096" node index.js
If you want to change the memory limits of Node.js for your entire environment, you need to set the following variable in your environment's configuration file. (
Add this line to your configuration file:
If you run into this issue when installing a package with npm or yarn, you can bypass the memory limit temporarily by installing the package as follows:
node --max-old-space-size=4096 $(which npm) install -g nextawesomelib
With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...
You name the business and I will tell you how web development can help you promote your business. If it is a startup or you seeking some...
Top 10 Web Development Trends in 2020 will provide you with a detailed list of the trends which are currently being noticed. Upskilling to these trends will help you in landing onto better jobs in 2020-2021.