<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Npm on Daniel Pomfret</title>
    <link>https://pomfret.uk/tags/npm/</link>
    <description>Recent content in Npm on Daniel Pomfret</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <copyright>© Daniel Pomfret</copyright>
    <lastBuildDate>Sun, 06 Sep 2020 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://pomfret.uk/tags/npm/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>NPM: Maximum call stack size exceeded</title>
      <link>https://pomfret.uk/posts/npm-maximum-call-stack-size-exceeded/</link>
      <pubDate>Sun, 06 Sep 2020 00:00:00 +0000</pubDate>
      <guid>https://pomfret.uk/posts/npm-maximum-call-stack-size-exceeded/</guid>
      <description>&lt;p&gt;You may have cloned a project and tried running &amp;rsquo;npm install&amp;rsquo; only to find the following error message:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;error Maximum call stack size exceeded&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There&amp;rsquo;s multiple ways I&amp;rsquo;ve found to fix this:&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-safe-ways&#34;&gt;The Safe ways:&lt;/h2&gt;&#xA;&lt;p&gt;Force clear the NPM cache:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;npm cache clean --force&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;npm install&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Rebuild:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;npm rebuild&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;npm install&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Remove node_modules:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;rm -r node_modules&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;npm install&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;the-nuclear-way&#34;&gt;The Nuclear way:&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;rm package-lock.json&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;rm -r node_modules&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;npm install&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As always, I hope this fixes your problem!&lt;/p&gt;</description>
    </item>
    <item>
      <title>npm install : Killed (Ubuntu 16.04)</title>
      <link>https://pomfret.uk/posts/npm-install-killed-ubuntu-16-04/</link>
      <pubDate>Wed, 21 Feb 2018 00:00:00 +0000</pubDate>
      <guid>https://pomfret.uk/posts/npm-install-killed-ubuntu-16-04/</guid>
      <description>&lt;p&gt;While installing packages via npm, it failed with just the message &amp;ldquo;Killed&amp;rdquo;. Automatically this triggers me to believe it is memory related. I was after all running the VM with only 1G memory.&lt;/p&gt;&#xA;&lt;h2 id=&#34;fix-npm-install-killed&#34;&gt;Fix npm install Killed&lt;/h2&gt;&#xA;&lt;p&gt;So to resolve this, you need to create and extend a swap file.&lt;/p&gt;&#xA;&lt;p&gt;You can do this in Ubuntu 14.04 and 16.04 with the following commands:&lt;/p&gt;&#xA;&lt;p&gt;sudo fallocate -l 1G /swapfile&#xA;sudo chmod 600 /swapfile&#xA;sudo mkswap /swapfile&#xA;sudo swapon /swapfile&#xA;sudo swapon &amp;ndash;show&#xA;sudo cp /etc/fstab /etc/fstab.bak&#xA;echo &amp;lsquo;/swapfile none swap sw 0 0&amp;rsquo; | sudo tee -a /etc/fstab&#xA;sudo sysctl vm.swappiness=10&#xA;echo &amp;lsquo;vm.swappiness=10&amp;rsquo; | sudo tee -a /etc/sysctl.conf&#xA;sudo sysctl vm.vfs_cache_pressure=50&#xA;echo &amp;lsquo;vm.vfs_cache_pressure=50&amp;rsquo; | sudo tee -a /etc/sysctl.conf&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
