{"id":810,"date":"2018-05-16T17:55:08","date_gmt":"2018-05-16T17:55:08","guid":{"rendered":"https:\/\/www.crccheck.com\/blog\/?p=810"},"modified":"2018-05-16T17:58:50","modified_gmt":"2018-05-16T17:58:50","slug":"installing-nvm-for-n-users","status":"publish","type":"post","link":"https:\/\/www.crccheck.com\/blog\/installing-nvm-for-n-users\/","title":{"rendered":"Installing nvm for n users"},"content":{"rendered":"<div class=\"highlight highlight-source-shell\">\n<p>I use <a href=\"https:\/\/github.com\/tj\/n\">n<\/a> to manage my system\/default NodeJS, but if I&#8217;m in a legacy repo (hint: pretty much every repo where I work) I&#8217;ll need to drop into an old version of NodeJS just for that terminal.<\/p>\n<p>Here&#8217;s how I install and use nvm. Based on the original instructions at: <a href=\"https:\/\/github.com\/creationix\/nvm\">github.com\/creationix\/nvm<\/a><\/p>\n<pre>curl -o- https:\/\/raw.githubusercontent.com\/creationix\/nvm\/v0.33.11\/install.sh\r\ncd ~\/.nvm\r\ngit remote rm origin\r\ngit remote add origin git@github.com:creationix\/nvm.git\r\n<\/pre>\n<p>Keep nvm from making you use a weird version of Node:<\/p>\n<pre>nvm alias default system\r\n<\/pre>\n<p>Don&#8217;t use nvm&#8217;s init script, use this instead:<\/p>\n<pre>if [ -d ~\/.nvm ]; then\r\n  export NVM_DIR=\"$HOME\/.nvm\"\r\n  [ -s \"$NVM_DIR\/nvm.sh\" ] &amp;&amp; \\. \"$NVM_DIR\/nvm.sh\"  # This loads nvm\r\n  [ -s \"$NVM_DIR\/bash_completion\" ] &amp;&amp; \\. \"$NVM_DIR\/bash_completion\"  # This loads nvm bash_completion\r\nelse\r\n  alias nvm='[ -f .nvmrc ] &amp;&amp; n $(cat .nvmrc) || echo \"MISSING: .nvmrc\"'\r\nfi\r\n<\/pre>\n<p>Tools like Husky will look for NVM environment variables. So for my non-work machines, I make sure none of them get set.<\/p>\n<\/div>\n<p>So what do I normally do if I need to do something in an old version of Node? This only comes up for me if a TravisCI builds for an old version. If the fix isn&#8217;t obvious, I&#8217;ll do <code>n 4<\/code> to get into Node 4, do my fix, then switch back to LTS.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I use n to manage my system\/default NodeJS, but if I&#8217;m in a legacy repo (hint: pretty much every repo where I work) I&#8217;ll need to drop into an old version of NodeJS just for that terminal. Here&#8217;s how I install and use nvm. Based on the original instructions at: github.com\/creationix\/nvm curl -o- https:\/\/raw.githubusercontent.com\/creationix\/nvm\/v0.33.11\/install.sh cd&hellip;<\/p>\n <a href=\"https:\/\/www.crccheck.com\/blog\/installing-nvm-for-n-users\/\" title=\"Installing nvm for n users\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">Installing nvm for n users<\/span><\/a>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[50],"tags":[83],"class_list":["entry","author-showmewhatyougot","post-810","post","type-post","status-publish","format-standard","category-best-practices","tag-node"],"_links":{"self":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/comments?post=810"}],"version-history":[{"count":4,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/810\/revisions"}],"predecessor-version":[{"id":814,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/810\/revisions\/814"}],"wp:attachment":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/media?parent=810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/categories?post=810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/tags?post=810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}