Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 165 lines (108 sloc) 5.2 kb
492924c @isaacs Move more of the documentation to ronn's domain
isaacs authored
1 # npm
4626dfa Initial drop. Ugly, sketchy, and not even yet quite a "work in progr…
isaacs authored
2
069a27c @isaacs Add a simpler install process up near the top.
isaacs authored
3 This is just enough info to get you up and running.
b3f1673 @isaacs another note pointing users to the documentation
isaacs authored
4
5e04f23 @isaacs Spruce up the install cmd a bit
isaacs authored
5 Much more info available via `npm help` once it's installed.
841f3b5 @isaacs Move the installing section up to the top
isaacs authored
6
266f1c9 @isaacs Update the README with more helpful info.
isaacs authored
7 ## IMPORTANT
8
9 You need node v0.2.0 or higher to run this program.
10
11 You shouldn't use sudo with it.
12
069a27c @isaacs Add a simpler install process up near the top.
isaacs authored
13 ## Simple Install
841f3b5 @isaacs Move the installing section up to the top
isaacs authored
14
5e04f23 @isaacs Spruce up the install cmd a bit
isaacs authored
15 To install npm with one command, do this:
d49a887 @isaacs add some more installation suggestions/options
isaacs authored
16
5885cbf @isaacs Update readme to reference super duper easy install script.
isaacs authored
17 curl http://npmjs.org/install.sh | sh
d49a887 @isaacs add some more installation suggestions/options
isaacs authored
18
5d6fb4b @isaacs the install script sometimes fails.
isaacs authored
19 If that fails, try this:
20
21 git clone http://github.com/isaacs/npm.git
22 cd npm
23 make
24
5e04f23 @isaacs Spruce up the install cmd a bit
isaacs authored
25 If you're sitting in the code folder reading this document in your
26 terminal, then you've already got the code. Just do:
27
28 make
29
30 and npm will install itself.
31
32 If you don't have make, and don't have curl or git, and ALL you have is
33 this code and node, you can do:
34
35 node ./cli.js install npm
36
0164a0d @isaacs Make the "don't use sudo" explanation clearer.
isaacs authored
37 ## Permission Errors
38
57729b7 @isaacs Documentation updates
isaacs authored
39 If it dies with a "Permission Denied" or EACCESS error, then that probably
266f1c9 @isaacs Update the README with more helpful info.
isaacs authored
40 means that you are running node in a shared root-owned location. You've
41 got options.
57729b7 @isaacs Documentation updates
isaacs authored
42
0164a0d @isaacs Make the "don't use sudo" explanation clearer.
isaacs authored
43 Using sudo with npm is Very Not Recommended. Anyone can publish anything,
44 and package installations can run arbitrary scripts.
45
46 ### Option 1: Take ownership
47
3901ac1 @isaacs Be more specific with the chown instructions
isaacs authored
48 Don't do this if you don't know what it does! If you have software in
49 /usr/local that depends on a specific ownership (such as MySQL), then it
50 might break if you change its ownership. Be careful. Unix does not
51 assume you don't know what you're doing!
0164a0d @isaacs Make the "don't use sudo" explanation clearer.
isaacs authored
52
3901ac1 @isaacs Be more specific with the chown instructions
isaacs authored
53 This is convenient if you have a single-user machine. Run this command
54 once, and never use sudo again to install stuff in /usr/local:
55
56 sudo chown -R $USER /usr/local/{share/man,bin,lib/node}
0164a0d @isaacs Make the "don't use sudo" explanation clearer.
isaacs authored
57
58 You could also give your user permission to write into that directory by
59 making it group-writable and adding your user to the group that owns it.
60
61 ### Option 2: Don't leave $HOME
62
63 Install node in `$HOME/local` and npm will default to living right alongside
64 it. Follow the steps in this gist: <http://gist.github.com/579814>
65
66 ### Option 3: Customize npm to your heart's content
67
68 Create and edit a file at `~/.npmrc`. This is an ini-formatted file, which
69 you can use to set npm configs. Do something like this to it:
70
71 cat >>~/.npmrc <<NPMRC
61fea1c @isaacs Make the .npmrc sample more clear, and add some words about sudoing
isaacs authored
72 root = ~/.node_libraries
73 binroot = ~/bin
74 manroot = ~/share/man
0164a0d @isaacs Make the "don't use sudo" explanation clearer.
isaacs authored
75 NPMRC
76
77 ### Option 4: HOLY COW NOT RECOMMENDED!!
78
79 You *can* just use sudo all the time for everything, and ignore the incredibly
80 obnoxious warnings telling you that you're insane for doing this.
81
82 # you must REALLY trust me to do this!
83 curl http://npmjs.org/install.sh | sudo sh
84 sudo npm ls
85 sudo npm install please-pwn-my-machine-kthx
86
87 If this causes horrible things to happen, you can't say I didn't warn you over
88 and over again until everyone got sick of hearing about it and told me to shut
89 up already.
d49a887 @isaacs add some more installation suggestions/options
isaacs authored
90
61fea1c @isaacs Make the .npmrc sample more clear, and add some words about sudoing
isaacs authored
91 It is on the roadmap to make npm do a bunch of chown/setuid stuff when sudoed,
92 so eventually it'll actually be *safer* to run as root than as a user account,
93 but that's a refactor that is slowly progressing.
94
95 If you have feelings about sudo use and what it should imply, then please go add
5e04f23 @isaacs Spruce up the install cmd a bit
isaacs authored
96 some comments and thoughts on
97 [this issue](http://github.com/isaacs/npm/issues/issue/294).
61fea1c @isaacs Make the .npmrc sample more clear, and add some words about sudoing
isaacs authored
98
069a27c @isaacs Add a simpler install process up near the top.
isaacs authored
99 ## More Fancy Installing
100
101 First, get the code. Maybe use git for this. That'd be cool. Very fancy.
102
bf84068 @isaacs update make stuff in the README
isaacs authored
103 The default make target is `install`, which downloads the current stable
895281c @isaacs Update install instructions.
isaacs authored
104 version of npm, and installs that for you.
069a27c @isaacs Add a simpler install process up near the top.
isaacs authored
105
895281c @isaacs Update install instructions.
isaacs authored
106 If you want to install the exact code that you're looking at, the bleeding-edge
107 master branch, do this:
108
bf84068 @isaacs update make stuff in the README
isaacs authored
109 make dev
069a27c @isaacs Add a simpler install process up near the top.
isaacs authored
110
111 If you'd prefer to just symlink in the current code so you can hack
112 on it, you can do this:
113
895281c @isaacs Update install instructions.
isaacs authored
114 make link
115
116 If you check out the Makefile, you'll see that these are just running npm commands
117 at the cli.js script directly. You can also use npm without ever installing
266f1c9 @isaacs Update the README with more helpful info.
isaacs authored
118 it by using `node cli.js` instead of "npm". Set up an alias if you want, that's
119 fine. (You'll still need read permission to the root/binroot/manroot folders,
120 but at this point, you probably grok all that anyway.)
069a27c @isaacs Add a simpler install process up near the top.
isaacs authored
121
c71ae65 @isaacs version notes for 0.1.11
isaacs authored
122 ## Uninstalling
123
124 So sad to see you go.
125
126 npm uninstall npm
127
128 Or, if that fails,
129
130 make uninstall
d9e9c14 @isaacs Point developers to the docs
isaacs authored
131
da8557a @isaacs document programmatic usage
isaacs authored
132 ## Using npm Programmatically
133
134 If you would like to use npm programmatically, you can do that as of
135 version 0.2.6. It's not very well documented, but it IS rather simple.
136
137 var npm = require("npm")
138 npm.load(myConfigObject, function (er) {
139 if (er) return handlError(er)
140 npm.commands.install(["some", "args"], function (er, data) {
141 if (er) return commandFailed(er)
142 // command succeeded, and data might have some info
143 })
144 npm.on("log", function (message) { .... })
145 })
146
147 See `./cli.js` for an example of pulling config values off of the
148 command line arguments. You may also want to check out `npm help
149 config` to learn about all the options you can set there.
150
151 As more features are added for programmatic access to the npm library,
152 this section will likely be split out into its own documentation page.
266f1c9 @isaacs Update the README with more helpful info.
isaacs authored
153
d9e9c14 @isaacs Point developers to the docs
isaacs authored
154 ## More Docs
155
5e04f23 @isaacs Spruce up the install cmd a bit
isaacs authored
156 Check out the [docs](http://github.com/isaacs/npm/blob/master/doc/),
157 especially the
158 [faq](http://github.com/isaacs/npm/blob/master/doc/faq.md#readme).
d9e9c14 @isaacs Point developers to the docs
isaacs authored
159
5e04f23 @isaacs Spruce up the install cmd a bit
isaacs authored
160 You can use the `npm help` command to read any of them.
5885cbf @isaacs Update readme to reference super duper easy install script.
isaacs authored
161
d9e9c14 @isaacs Point developers to the docs
isaacs authored
162 If you're a developer, and you want to use npm to publish your program,
163 you should
164 [read this](http://github.com/isaacs/npm/blob/master/doc/developers.md#readme)
Something went wrong with that request. Please try again.