Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>npm install</code> installs packages either <a href="http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/" rel="noreferrer">locally or globally</a>:</p> <ul> <li><strong>Locally</strong>: <code>npm</code> looks for an existing folder called <code>node_modules</code> in the current directory and creates a folder for each package you install in that folder. If it can't find an existing <code>node_modules</code> folder here, it then looks through the current directory's ancestors until it finds one. If it can't find one, it creates one in the current directory.</li> <li><strong>Globally</strong>: if you use the <code>-g</code> (global) option, the package is installed in a global location. This location varies per Linux distribution, but <code>/usr/local/lib/node_modules/packagename</code> is one example. CentOS7 uses <code>/usr/lib/node_modules/packagename</code>.</li> </ul> <p>You should only use <code>-g</code> when the package is something you'd want to use as a command.</p> <blockquote> <p>Just like how global variables are kind of gross, but also necessary in some cases, global packages are important, but best avoided if not needed.</p> <p>In general, the rule of thumb is:</p> <ol> <li>If you’re installing something that you want to use in your program, using <code>require('whatever')</code>, then install it locally, at the root of your project.</li> <li>If you’re installing something that you want to use in your <em>shell</em>, on the command line or something, install it globally, so that its binaries end up in your <code>PATH</code> environment variable.</li> </ol> </blockquote> <p>npm will not install a package's files directly into the current directory.</p> <p>However, this is actually a good thing. It keeps dependencies' files separate from your app, and <a href="http://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders" rel="noreferrer">Node automatically searches the <code>node_modules</code> folder when you <code>require</code> something</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload