Install Node on OSX El Capitan for beginner

Problems when installing Node on OSX with brews, the default node path on OSX. For some reason my node modules where all installed in /Users//.npm_packages and Node Modules end up here 


This result in a lot of errors when i try to install JS-Minify for Sublime Text. special if i install modules Globally. 

This is a BlogLog post to reproduce the path if sometime a similar Error occurs in my node environment. At the end you find the stackoverflow links who helped to solve most problems

Installing node through Homebrew can cause problems with npm for globally installed packages. .
$ rm -rf /usr/local/lib/node_modules $ brew uninstall node $ brew install node --without-npm $ echo prefix=~/.npm-packages >> ~/.npmrc $ curl -L | sh </code></p> <p>to the new npm to  PATH environment variable <code class="prettyprint">$ export PATH="$HOME/.npm-packages/bin:$PATH"</code></p> <p>To make the new Path permanent we add it to our .bash_profile add following line <code> #NODE GLOBAL PATH PATH=$HOME/.npm-packages/bin:$PATH </code></p> <p>Reload the bash in Terminal</p> <p><code>source ~/.bash_profile</code></p> <p>Check PATH <code>$ echo $PATH</code></p> <p>Edit $PATH</p> <p><span>vi $HOME/.bash_profile</span></p> <h2>NODE Commands:</h2> <p><code>$ npm config get prefix</code></p> <p><strong><em>Show Version</em></strong></p> <p>$ npm -v</p> <p><strong><em>Show node Version</em></strong></p> <p><span>$ node –version </span></p> <p><em><strong>Get Path where NPM is installed</strong></em></p> <pre class="lang-js prettyprint prettyprinted"><code><span class="pln">$ npm config </span><span class="kwd">get</span><span class="pln"> prefix</span></code>

Set the nvm default Dir DONT use Sudo

$ npm config set prefix /usr/local

List Global NPM Packages
$ npm list -g

Will show the global installation root regardless of current working directory.

npm root -g</code><span> </span></p> <h4 class="gh-header-title instapaper_title">Complete Remove NODE.JS</h4> <pre class="lang-bash prettyprint prettyprinted"><code><span class="pln">brew uninstall node</span><span class="pun">;</span><span class="pln"> </span><span class="com"># or `brew uninstall --force node` which removes all versions</span><span class="pln"> brew prune</span><span class="pun">;</span><span class="pln"> rm </span><span class="pun">-</span><span class="pln">f </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">npm </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">lib</span><span class="pun">/</span><span class="pln">dtrace</span><span class="pun">/</span><span class="pln">node</span><span class="pun">.</span><span class="pln">d</span><span class="pun">;</span><span class="pln"> rm </span><span class="pun">-</span><span class="pln">rf </span><span class="pun">~/.</span><span class="pln">npm</span><span class="pun">;</span></code>

Reinstall  NODE.JS

brew install node;
which node # => /usr/local/bin/node
export NODE_PATH='/usr/local/lib/node_modules' # <--- add this ~/.bashrc

Get Node info regarding your node installs

brew info node

Temporary show hidden Files

defaults write AppleShowAllFiles TRUE

killall Finder

and at the end set back to hide the files again

defaults write AppleShowAllFiles FALSE

killall Finder

Installing global node modules

Installing Node MAC Linux Nodeschool 

Complete Unistall & reinstall Node  

Install Minify for Sublime Text 


Source : DAnHerbert GIST