{"id":6256,"date":"2019-07-29T08:39:19","date_gmt":"2019-07-29T08:39:19","guid":{"rendered":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?p=6256"},"modified":"2019-07-29T08:39:19","modified_gmt":"2019-07-29T08:39:19","slug":"prevent-npm-install-from-being-killed-by-checking-the-swap-file","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/","title":{"rendered":"Prevent NPM Install from Being Killed by Checking the Swap File"},"content":{"rendered":"<p>Sometimes you are unable to perform npm install. You might face issues like command getting freezed, and after few minutes, npm displays \u2018Killed\u2019 message and breaks.<\/p>\n<p>You can try several ways to resolve this issue as below:<\/p>\n<ol>\n<li>Install npm with every single dependency in package.json (about 20 dependencies, mostly grunt related).<\/li>\n<li>In package.json, remove ^ and ~ character to ensure npm only fetches correct version of dependencies (don\u2019t compare and get latest version).<\/li>\n<li>Note that bower installation can go normal with about ~10 dependencies of AngularJS.<\/li>\n<\/ol>\n<p>Try to <em>npm rm -rf node_modules &amp;&amp; npm cache clean<\/em>, then npm install again does not work too, npm still be killed.<\/p>\n<h3>Steps to Prevent npm Install From Being Killed<\/h3>\n<p>This issue occurs mainly due to dirty workspace of node modules and for that you just need to clean the cache. But still for many the problem still persists. Many face the issue that the command runs on the local machine without any problem and the remote machine comprises of the same environment too. The difference is only about the machine configuration.<\/p>\n<p><strong>Check the example of configuration:<\/strong><\/p>\n<ul>\n<li><strong>Local Machine Configuration:<\/strong> Dual core 1.3Ghz, with 4GB RAM and 4GB swap file, 256GB SSD.<\/li>\n<li><strong>Remote Machine Configuration:<\/strong> Single core CPU, with 512MB RAM and 20GB SSD<\/li>\n<li>Even with this configuration you get an error <em>npm install<\/em> was Killed, after laggy (|) rotation<\/li>\n<\/ul>\n<p>So, you can see that the biggest difference is memory. Here the remote machine (which is running Apache, nginx and MySQL) doesn\u2019t have enough memory for npm to build something during the installation of dependencies \u2013 many dependencies need to be rebuilt by make.<\/p>\n<p>For this check your swap file in remote machine using the below command:<\/p>\n<pre class=\"lang:default decode:true \">sudo swapon -s<\/pre>\n<p>You will get the result as no swap file are available:<\/p>\n<pre class=\"lang:default decode:true \">Filename\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Type\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Size\u00a0\u00a0\u00a0 Used\u00a0\u00a0\u00a0 Priority<\/pre>\n<p>Then create a 1GB swap file (on SSD system, swap speed can be much faster)<\/p>\n<pre class=\"lang:default decode:true \">sudo dd if=\/dev\/zero of=\/swapfile bs=1024 count=1024k<\/pre>\n<p>Prepare the swap file using the below command:<\/p>\n<pre class=\"lang:default decode:true \">sudo mkswap \/swapfile<\/pre>\n<p>And activate it by executing this command:<\/p>\n<pre class=\"lang:default decode:true \">sudo swapon \/swapfile<\/pre>\n<p>Continue swap file after reboot by copying configuration on to the below path:<\/p>\n<pre class=\"lang:default decode:true \">sudo nano \/etc\/fstab<\/pre>\n<pre class=\"lang:default decode:true \">\/swapfile none swap sw 0 0<\/pre>\n<p>To make swap file to be a buffer for securing the application crashes, use the below command:<\/p>\n<pre class=\"lang:default decode:true \">echo 10 | sudo tee \/proc\/sys\/vm\/swappiness echo vm.swappiness = 10 | sudo tee -a \/etc\/sysctl.conf<\/pre>\n<p>Lastly, set correct permission on it:<\/p>\n<pre class=\"lang:default decode:true \">sudo chown root:root \/swapfile sudo chmod 0600 \/swapfile<\/pre>\n<p>Then, clean cache and rebuild with npm:<\/p>\n<pre class=\"lang:default decode:true \">npm cache clean npm install<\/pre>\n<p>That\u2019s it! Install script is successfully completed. It takes just about 5 minutes for npm and make to build and install required dependencies. Then just npm start and your dashboard is online!<\/p>\n<h3>Conclusion<\/h3>\n<p>If you already succeed in something and fail with the same tasks, make sure to check what is different along with the software and hardware to detect the reason of failure.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you are unable to perform npm install. You might face issues like command getting freezed, and after few minutes, npm displays \u2018Killed\u2019 message and breaks. You can try several ways to resolve this issue as below: Install npm with every single dependency in package.json (about 20 dependencies, mostly grunt related). In package.json, remove ^ [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[918,630,917],"class_list":["post-6256","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-web-hosting-faq","tag-check-swap-file","tag-linux","tag-npm-install"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Prevent NPM Install from Being Killed by Checking the Swap File<\/title>\n<meta name=\"description\" content=\"The article provides steps to prevent npm install from being killed by checking the swap file.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Prevent NPM Install from Being Killed by Checking the Swap File\" \/>\n<meta property=\"og:description\" content=\"The article provides steps to prevent npm install from being killed by checking the swap file.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2019-07-29T08:39:19+00:00\" \/>\n<meta name=\"author\" content=\"Pallavi Godse\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pallavi Godse\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/\",\"name\":\"Prevent NPM Install from Being Killed by Checking the Swap File\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\"},\"datePublished\":\"2019-07-29T08:39:19+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\"},\"description\":\"The article provides steps to prevent npm install from being killed by checking the swap file.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Prevent NPM Install from Being Killed by Checking the Swap File\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945\",\"name\":\"Pallavi Godse\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g\",\"caption\":\"Pallavi Godse\"},\"description\":\"Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/pallavi\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Prevent NPM Install from Being Killed by Checking the Swap File","description":"The article provides steps to prevent npm install from being killed by checking the swap file.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/","og_locale":"en_GB","og_type":"article","og_title":"Prevent NPM Install from Being Killed by Checking the Swap File","og_description":"The article provides steps to prevent npm install from being killed by checking the swap file.","og_url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2019-07-29T08:39:19+00:00","author":"Pallavi Godse","twitter_misc":{"Written by":"Pallavi Godse","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/","name":"Prevent NPM Install from Being Killed by Checking the Swap File","isPartOf":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website"},"datePublished":"2019-07-29T08:39:19+00:00","author":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945"},"description":"The article provides steps to prevent npm install from being killed by checking the swap file.","breadcrumb":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/prevent-npm-install-from-being-killed-by-checking-the-swap-file\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"Prevent NPM Install from Being Killed by Checking the Swap File"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/7e3952607fa9eb4e82fea9f7cad9c945","name":"Pallavi Godse","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/eefc9695ea2b2c6e143c9c9919701aaa?s=96&d=blank&r=g","caption":"Pallavi Godse"},"description":"Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/pallavi\/"}]}},"views":691,"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/6256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=6256"}],"version-history":[{"count":1,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/6256\/revisions"}],"predecessor-version":[{"id":6257,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/6256\/revisions\/6257"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=6256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=6256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=6256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}