increase-memory-limit command not found - node.js

I wanted to increase the heap size of my node project. So I installed increase-memory-limit package.
But when I execute increase-memory-limit in the terminal I get an error of "increase-memory-limit: command not found". Please help me if I am missing something.
thanks in advance.

Not sure why you need a module for that.
Just pass a value to the --max_old_space_size V8 flag when you're starting up your server. For example, if you're using index.js as the entry point and you want 2048 MB of managed heap you would do:
$ node --max_old_space_size=2048 index.js
Do note that V8 flags should be declared before the file you want to run.

Related

Angular 8 error: '"node --max-old-space-size=10240"' is not recognized as an internal or external command

First I had the issue with limit allocation and I tried to resolve that using this answers here:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory in ionic 3
But after that, I have this issue:
I didn't type this number 10240... I don't know where is this number from and how to solve the problem. Any idea?
Finally, I deleted the existing node module folder from my project and run the below commands:
npm install -all
npm audit fix
If anyone else is still having this issue: the solution for me was to run a script via node once, which converts all "%prog%" into %prog% in each cmd file in node-modules like this one

Global command $ live-server on git-bash can't be found?

When I try to run $ live-server globally I get the following error:
C:\Users\name\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found
I'm thinking it must be looking in the wrong place for some reason. The following returns:
$ npm bin -g
C:\Users\name\AppData\Roaming\npm
Anyone have any ideas why?
This is followed by node/issue 29287 which points to the same recommendation:
I deleted my C:/Users/{username}/AppData/Roaming/npm and C:/Users/{username}/AppData/Roaming/npm-cache and reinstalled global npm modules, and the problem ceased.
It would be much better though if these steps could be avoided after upgrading/downgrading node.
If not, then at least, make it explicit in the docs that this step may be necessary when upgrading/downgrading existing node installations.

Nodejs Appveyor build running out of memory

We're running builds on AppVeyor to build an AOT angular 2 application.
The build has started failing, giving the following:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
From what I can tell, you can use --max_old_space_size=xxxx where xxxx is the size you want to increase memory to. The default is 512.
The problem is, I'm not sure where to add this flag. I've tried both dashes (what I found originall) and underscores. I've placed the flag as part of the ps build command definition, in the build scripts build configuration, and in the package.json scripts definitions to no avail.
I'm sure this just has to be put in the right spot, but I'm unclear as to where to add it. Any help would be appreciated.
Thanks
In appveyor.yml:
init:
- ps: Install-Product node 8
- cmd: set NODE_OPTIONS=--max-old-space-size=1028
This sets a node env var during init. Set it as high as you like.
This reduced build times for us by about 80% as well. Incredible.

ubuntu 14.04 LTS webpack --watch not recompiling after a few times

I'm using Webpack along with Babel to compile my jsx into js. --watch will work a few times but then stop afterwards. I've had to resort to manually typing in webpack every time in order to make sure my scripts get compiled.
I had a similar problem to this where it turned out that webpack was silently failing to report that I had exceeded the max number of inotify watchers in Linux. Webpack watch uses inotify to observe file changes.
You can immediately try a fix to see if it works with:
sudo -i
echo 1048576 > /proc/sys/fs/inotify/max_user_watches
exit
The long term fix would be to increase your allowed watchers by editing your /etc/sysctl.conf to include this line: fs.inotify.max_user_watches=1048576.
The issue was reported here: https://github.com/webpack/webpack/issues/1281

Starting Meteor dev from NPM scripts causes CPU spike

Picking up on a suggestion I read, I thought I would try starting my Meteor processes in dev mode from npm scripts in package.json files, since I have some verbose startup settings. I'm aware that I can use a bash script or the like but npm run whatever seemed like a nice clean solution.
Unfortunately doing this causes huge CPU spikes that render my system unusable. For example, running meteor -p 6001 and meteor -p 7001 yields two node processes utilizing 0.3% CPU each. But running npm run appA and npm run appB where the scripts point to the same commands above yields a first node process utilizing over 70% of CPU, and a second process over 100%.
Apparently this is not doing what I thought it was doing. It's not mission-critical but I'd love to learn what's going on under the hood or, even better, a fix. I'm running node version 5.4.1 and Meteor version 1.2.1 (which utilizes node version 0.10.40).
Can someone explain what's causing this?
Exactly same thing happened here, glad to find out that this is because of npm script, I was thinking that I'm due to deep profiling my app to find what's wrong.
Would love an explanation and a fix too.

Resources