title: sudo: npm: command not found
body: <p>I'm trying to upgrade to the latest version of node. I'm following the instructions at <a href="http://davidwalsh.name/upgrade-nodejs" rel="noreferrer">http://davidwalsh.name/upgrade-nodejs</a></p>
  
  <p>But when I do:</p>
  
  <pre><code>sudo npm install -g n
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>sudo: npm: command not found
  </code></pre>
  
  <p>npm works without sudo. When I do:</p>
  
  <pre><code>whereis node
  </code></pre>
  
  <p>I see:</p>
  
  <pre><code>node: /usr/bin/node /usr/lib/node /usr/bin/X11/node /usr/local/node
  </code></pre>
  
  <p>Running:</p>
  
  <pre><code>which npm
  </code></pre>
  
  <p>Shows:</p>
  
  <pre><code>/usr/local/node/bin/npm
  </code></pre>
  
  <p>I tried the solution at <a href="https://stackoverflow.com/a/5062718/1246159">https://stackoverflow.com/a/5062718/1246159</a></p>
  
  <p>But I'm still getting the same error. I also looked at the /etc/sudoers file and the relevant line is:</p>
  
  <pre><code>Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  </code></pre>
  
  <p>This looks fine to me. How can I possibly get NPM working with sudo command?</p>