mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
312 lines
12 KiB
312 lines
12 KiB
13 years ago
|
<!doctype html>
|
||
|
<html>
|
||
|
<title>README</title>
|
||
|
<meta http-equiv="content-type" value="text/html;utf-8">
|
||
|
<link rel="stylesheet" type="text/css" href="./style.css">
|
||
|
|
||
|
<body>
|
||
|
<div id="wrapper">
|
||
|
<h1><a href="../doc/npm.html">npm</a></h1> <p>node package manager</p>
|
||
|
|
||
|
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||
|
|
||
|
<p>This is just enough info to get you up and running.</p>
|
||
|
|
||
|
<p>Much more info available via <code>npm help</code> once it's installed.</p>
|
||
|
|
||
|
<h2 id="IMPORTANT">IMPORTANT</h2>
|
||
|
|
||
|
<p><strong>You need node v0.4 or higher to run this program.</strong></p>
|
||
|
|
||
|
<p>To install an old <strong>and unsupported</strong> version of npm that works on node 0.3
|
||
|
and prior, clone the git repo and dig through the old tags and branches.</p>
|
||
|
|
||
|
<h2 id="Simple-Install-Unix-only-sorry">Simple Install (Unix only, sorry)</h2>
|
||
|
|
||
|
<p>To install npm with one command, do this:</p>
|
||
|
|
||
|
<pre><code>curl http://npmjs.org/install.sh | sh</code></pre>
|
||
|
|
||
|
<p>To skip the npm 0.x cleanup, do this:</p>
|
||
|
|
||
|
<pre><code>curl http://npmjs.org/install.sh | clean=no sh</code></pre>
|
||
|
|
||
|
<p>To say "yes" to the 0.x cleanup, but skip the prompt:</p>
|
||
|
|
||
|
<pre><code>curl http://npmjs.org/install.sh | clean=yes sh</code></pre>
|
||
|
|
||
|
<p>If you get permission errors, see the section below, entitled
|
||
|
"Permission Errors on Installation".</p>
|
||
|
|
||
|
<h2 id="Installing-on-Windows-Experimental">Installing on Windows -- Experimental</h2>
|
||
|
|
||
|
<p>Yes, this sucks. A convenient one-liner is coming soon.</p>
|
||
|
|
||
|
<h3 id="Step-1-Drop-the-node-exe-somewhere">Step 1: Drop the node.exe somewhere</h3>
|
||
|
|
||
|
<p>You will probably need the latest version of node, <strong>at least</strong> version
|
||
|
<code>0.5.8</code> or higher. You can get it from
|
||
|
<a href="http://nodejs.org/dist/v0.5.8/node.exe">http://nodejs.org/dist/v0.5.8/node.exe</a>.</p>
|
||
|
|
||
|
<h3 id="Step-2-optional-Update-the-PATH-environment-variable">Step 2 (optional): Update the %PATH% environment variable</h3>
|
||
|
|
||
|
<p>Update your <code>%PATH%</code> environment variable in System Properties:
|
||
|
Advanced: Environment, so that it includes the <code>bin</code> folder you chose.
|
||
|
The entries are separated by semicolons.</p>
|
||
|
|
||
|
<p>You <em>may</em> be able to do this from the command line using <code>set</code> and
|
||
|
<code>setx</code>. <code>cd</code> into the <code>bin</code> folder you created in step 1, and do this:</p>
|
||
|
|
||
|
<pre><code>set path=%PATH%;%CD%
|
||
|
setx path "%PATH%"</code></pre>
|
||
|
|
||
|
<p>This will have the added advantage that you'll be able to simply type
|
||
|
<code>npm</code> or <code>node</code> in any project folder to access those commands.</p>
|
||
|
|
||
|
<p>If you decide not to update the PATH, and put the node.exe file in
|
||
|
<code>C:\node\node.exe</code>, then the npm executable will end up <code>C:\node\npm.cmd</code>,
|
||
|
and you'll have to type <code>C:\node\npm <command></code> to use it.</p>
|
||
|
|
||
|
<h3 id="Step-3-Install-git">Step 3: Install git</h3>
|
||
|
|
||
|
<p>If you don't already have git,
|
||
|
<a href="https://git.wiki.kernel.org/index.php/MSysGit:InstallMSysGit">install it</a>.</p>
|
||
|
|
||
|
<p>Run <code>git --version</code> to make sure that it's at least version 1.7.6.</p>
|
||
|
|
||
|
<h3 id="Step-4-install-npm">Step 4: install npm</h3>
|
||
|
|
||
|
<p>Lastly, <strong>after</strong> node.exe, git, and your %PATH% have <em>all</em> been set up
|
||
|
properly, install npm itself:</p>
|
||
|
|
||
|
<pre><code>git config --system http.sslcainfo /bin/curl-ca-bundle.crt
|
||
|
git clone --recursive git://github.com/isaacs/npm.git
|
||
|
cd npm
|
||
|
node cli.js install npm -gf</code></pre>
|
||
|
|
||
|
<h2 id="Permission-Errors-EACCES-or-EACCESS-on-Installation">Permission Errors (`EACCES` or `EACCESS`) on Installation</h2>
|
||
|
|
||
|
<p>On Windows, you may need to run the command prompt in elevated
|
||
|
permission mode. (Right-click on cmd.exe, Run as Administrator.)</p>
|
||
|
|
||
|
<p>On Unix, you may need to run as root, or use <code>sudo</code>.</p>
|
||
|
|
||
|
<p><strong>Note</strong>: You would need to <code>sudo</code> the <code>sh</code>, <strong>not</strong> the <code>curl</code>. Fetching
|
||
|
stuff from the internet typically doesn't require elevated permissions.
|
||
|
Running it might.</p>
|
||
|
|
||
|
<p>I highly recommend that you first download the file, and make sure that
|
||
|
it is what you expect, and <em>then</em> run it.</p>
|
||
|
|
||
|
<pre><code>curl -O http://npmjs.org/install.sh
|
||
|
# inspect file..
|
||
|
sudo sh install.sh</code></pre>
|
||
|
|
||
|
<h2 id="Installing-on-Cygwin">Installing on Cygwin</h2>
|
||
|
|
||
|
<p>No.</p>
|
||
|
|
||
|
<h2 id="Dev-Install">Dev Install</h2>
|
||
|
|
||
|
<p>To install the latest <strong>unstable</strong> development version from git:</p>
|
||
|
|
||
|
<pre><code>git clone https://github.com/isaacs/npm.git
|
||
|
cd npm
|
||
|
git submodule update --init --recursive
|
||
|
sudo make install # (or: `node cli.js install -gf`)</code></pre>
|
||
|
|
||
|
<p>If you're sitting in the code folder reading this document in your
|
||
|
terminal, then you've already got the code. Just do:</p>
|
||
|
|
||
|
<pre><code>git submodule update --init --recursive
|
||
|
sudo make install</code></pre>
|
||
|
|
||
|
<p>and npm will install itself.</p>
|
||
|
|
||
|
<p>If you don't have make, and don't have curl or git, and ALL you have is
|
||
|
this code and node, you can probably do this:</p>
|
||
|
|
||
|
<pre><code>git submodule update --init --recursive
|
||
|
sudo node ./cli.js install -g</code></pre>
|
||
|
|
||
|
<p>Note that github tarballs <strong>do not contain submodules</strong>, so
|
||
|
those won't work. You'll have to also fetch the appropriate submodules
|
||
|
listed in the .gitmodules file.</p>
|
||
|
|
||
|
<h2 id="Permissions-when-Using-npm-to-Install-Other-Stuff">Permissions when Using npm to Install Other Stuff</h2>
|
||
|
|
||
|
<p><strong>tl;dr</strong></p>
|
||
|
|
||
|
<ul><li>Use <code>sudo</code> for greater safety. Or don't, if you prefer not to.</li><li>npm will downgrade permissions if it's root before running any build
|
||
|
scripts that package authors specified.</li></ul>
|
||
|
|
||
|
<h3 id="More-details">More details...</h3>
|
||
|
|
||
|
<p>As of version 0.3, it is recommended to run npm as root.
|
||
|
This allows npm to change the user identifier to the <code>nobody</code> user prior
|
||
|
to running any package build or test commands.</p>
|
||
|
|
||
|
<p>If you are not the root user, or if you are on a platform that does not
|
||
|
support uid switching, then npm will not attempt to change the userid.</p>
|
||
|
|
||
|
<p>If you would like to ensure that npm <strong>always</strong> runs scripts as the
|
||
|
"nobody" user, and have it fail if it cannot downgrade permissions, then
|
||
|
set the following configuration param:</p>
|
||
|
|
||
|
<pre><code>npm config set unsafe-perm false</code></pre>
|
||
|
|
||
|
<p>This will prevent running in unsafe mode, even as non-root users.</p>
|
||
|
|
||
|
<h2 id="Uninstalling">Uninstalling</h2>
|
||
|
|
||
|
<p>So sad to see you go.</p>
|
||
|
|
||
|
<pre><code>sudo npm uninstall npm -g</code></pre>
|
||
|
|
||
|
<p>Or, if that fails,</p>
|
||
|
|
||
|
<pre><code>sudo make uninstall</code></pre>
|
||
|
|
||
|
<h2 id="More-Severe-Uninstalling">More Severe Uninstalling</h2>
|
||
|
|
||
|
<p>Usually, the above instructions are sufficient. That will remove
|
||
|
npm, but leave behind anything you've installed.</p>
|
||
|
|
||
|
<p>If you would like to remove all the packages that you have installed,
|
||
|
then you can use the <code>npm ls</code> command to find them, and then <code>npm rm</code> to
|
||
|
remove them.</p>
|
||
|
|
||
|
<p>To remove cruft left behind by npm 0.x, you can use the included
|
||
|
<code>clean-old.sh</code> script file. You can run it conveniently like this:</p>
|
||
|
|
||
|
<pre><code>npm explore npm -g -- sh scripts/clean-old.sh</code></pre>
|
||
|
|
||
|
<p>npm uses two configuration files, one for per-user configs, and another
|
||
|
for global (every-user) configs. You can view them by doing:</p>
|
||
|
|
||
|
<pre><code>npm config get userconfig # defaults to ~/.npmrc
|
||
|
npm config get globalconfig # defaults to /usr/local/etc/npmrc</code></pre>
|
||
|
|
||
|
<p>Uninstalling npm does not remove configuration files by default. You
|
||
|
must remove them yourself manually if you want them gone. Note that
|
||
|
this means that future npm installs will not remember the settings that
|
||
|
you have chosen.</p>
|
||
|
|
||
|
<h2 id="Using-npm-Programmatically">Using npm Programmatically</h2>
|
||
|
|
||
|
<p>If you would like to use npm programmatically, you can do that.
|
||
|
It's not very well documented, but it <em>is</em> rather simple.</p>
|
||
|
|
||
|
<pre><code>var npm = require("npm")
|
||
|
npm.load(myConfigObject, function (er) {
|
||
|
if (er) return handlError(er)
|
||
|
npm.commands.install(["some", "args"], function (er, data) {
|
||
|
if (er) return commandFailed(er)
|
||
|
// command succeeded, and data might have some info
|
||
|
})
|
||
|
npm.on("log", function (message) { .... })
|
||
|
})</code></pre>
|
||
|
|
||
|
<p>The <code>load</code> function takes an object hash of the command-line configs.
|
||
|
The various <code>npm.commands.<cmd></code> functions take an <strong>array</strong> of
|
||
|
positional argument <strong>strings</strong>. The last argument to any
|
||
|
<code>npm.commands.<cmd></code> function is a callback. Some commands take other
|
||
|
optional arguments. Read the source.</p>
|
||
|
|
||
|
<p>You cannot set configs individually for any single npm function at this
|
||
|
time. Since <code>npm</code> is a singleton, any call to <code>npm.config.set</code> will
|
||
|
change the value for <em>all</em> npm commands in that process.</p>
|
||
|
|
||
|
<p>See <code>./bin/npm-cli.js</code> for an example of pulling config values off of the
|
||
|
command line arguments using nopt. You may also want to check out <code>npm
|
||
|
help config</code> to learn about all the options you can set there.</p>
|
||
|
|
||
|
<h2 id="More-Docs">More Docs</h2>
|
||
|
|
||
|
<p>Check out the <a href="http://npmjs.org/doc/">docs</a>,
|
||
|
especially the
|
||
|
<a href="http://npmjs.org/doc/faq.html">faq</a>.</p>
|
||
|
|
||
|
<p>You can use the <code>npm help</code> command to read any of them.</p>
|
||
|
|
||
|
<p>If you're a developer, and you want to use npm to publish your program,
|
||
|
you should
|
||
|
<a href="http://npmjs.org/doc/developers.html">read this</a></p>
|
||
|
|
||
|
<h2 id="Legal-Stuff">Legal Stuff</h2>
|
||
|
|
||
|
<p>"npm" and "the npm registry" are owned by Isaac Z. Schlueter. All
|
||
|
rights not explicitly granted in the MIT license are reserved. See the
|
||
|
included LICENSE file for more details.</p>
|
||
|
|
||
|
<p>"Node.js" and "node" are trademarks owned by Joyent, Inc. npm is not
|
||
|
officially part of the Node.js project, and is neither owned by nor
|
||
|
officially affiliated with Joyent, Inc.</p>
|
||
|
|
||
|
<p>The packages in the npm registry are not part of npm itself, and are the
|
||
|
sole property of their respective maintainers. While every effort is
|
||
|
made to ensure accountability, there is absolutely no guarantee,
|
||
|
warrantee, or assertion made as to the quality, fitness for a specific
|
||
|
purpose, or lack of malice in any given npm package. Modules
|
||
|
published on the npm registry are not affiliated with or endorsed by
|
||
|
Joyent, Inc., Isaac Z. Schlueter, Ryan Dahl, or the Node.js project.</p>
|
||
|
|
||
|
<p>If you have a complaint about a package in the npm registry, and cannot
|
||
|
resolve it with the package owner, please express your concerns to
|
||
|
Isaac Z. Schlueter at <a href="mailto:i@izs.me">i@izs.me</a>.</p>
|
||
|
|
||
|
<h3 id="In-plain-english">In plain english</h3>
|
||
|
|
||
|
<p>This is mine; not my employer's, not Node's, not Joyent's, not Ryan
|
||
|
Dahl's.</p>
|
||
|
|
||
|
<p>If you publish something, it's yours, and you are solely accountable
|
||
|
for it. Not me, not Node, not Joyent, not Ryan Dahl.</p>
|
||
|
|
||
|
<p>If other people publish something, it's theirs. Not mine, not Node's,
|
||
|
not Joyent's, not Ryan Dahl's.</p>
|
||
|
|
||
|
<p>Yes, you can publish something evil. It will be removed promptly if
|
||
|
reported, and we'll lose respect for you. But there is no vetting
|
||
|
process for published modules.</p>
|
||
|
|
||
|
<p>If this concerns you, inspect the source before using packages.</p>
|
||
|
|
||
|
<h2 id="SEE-ALSO">SEE ALSO</h2>
|
||
|
|
||
|
<ul><li><a href="../doc/npm.html">npm(1)</a></li><li><a href="../doc/faq.html">faq(1)</a></li><li><a href="../doc/help.html">help(1)</a></li><li><a href="../doc/index.html">index(1)</a></li></ul>
|
||
|
</div>
|
||
|
<p id="footer"><a href="../doc/README.html">README</a> — npm@1.1.0-alpha-2</p>
|
||
|
<script>
|
||
|
;(function () {
|
||
|
var wrapper = document.getElementById("wrapper")
|
||
|
var els = Array.prototype.slice.call(wrapper.getElementsByTagName("*"), 0)
|
||
|
.filter(function (el) {
|
||
|
return el.parentNode === wrapper
|
||
|
&& el.tagName.match(/H[1-6]/)
|
||
|
&& el.id
|
||
|
})
|
||
|
var l = 2
|
||
|
, toc = document.createElement("ul")
|
||
|
toc.innerHTML = els.map(function (el) {
|
||
|
var i = el.tagName.charAt(1)
|
||
|
, out = ""
|
||
|
while (i > l) {
|
||
|
out += "<ul>"
|
||
|
l ++
|
||
|
}
|
||
|
while (i < l) {
|
||
|
out += "</ul>"
|
||
|
l --
|
||
|
}
|
||
|
out += "<li><a href='#" + el.id + "'>" +
|
||
|
( el.innerText || el.text || el.innerHTML)
|
||
|
+ "</a>"
|
||
|
return out
|
||
|
}).join("\n")
|
||
|
toc.id = "toc"
|
||
|
document.body.appendChild(toc)
|
||
|
})()
|
||
|
</script>
|
||
|
</body></html>
|