@@ -32,35 +32,65 @@ tl;dr:
32
32
something with the ` -g ` flag, then its executables go in ` npm bin -g `
33
33
and its modules go in ` npm root -g ` .
34
34
35
- ## How do I install something everywhere ?
35
+ ## How do I install something on my computer in a central location ?
36
36
37
- Install it globally by tacking ` -g ` or ` --global ` to the command.
37
+ Install it globally by tacking ` -g ` or ` --global ` to the command. (This
38
+ is especially important for command line utilities that need to add
39
+ their bins to the global system ` PATH ` .)
38
40
39
41
## I installed something globally, but I can't ` require() ` it
40
42
41
43
Install it locally.
42
44
43
- ## I don't wanna.
45
+ The global install location is a place for command-line utilities
46
+ to put their bins in the system ` PATH ` . It's not for use with ` require() ` .
44
47
45
- Check out ` npm link ` . You might like it.
48
+ If you ` require() ` a module in your code, then that means it's a
49
+ dependency, and a part of your program. You need to install it locally
50
+ in your program.
46
51
47
- ## No, I really want 0.x style ' everything global' style.
52
+ ## Why can't npm just put everything in one place, like other package managers?
48
53
49
- Ok, fine. Do this:
54
+ Not every change is an improvement, but every improvement is a change.
55
+ This would be like asking git to do network IO for every commit. It's
56
+ not going to happen, because it's a terrible idea that causes more
57
+ problems than it solves.
50
58
51
- echo 'export NODE_PATH="'$(npm root -g)'"' >> ~/.bashrc
52
- . ~/.bashrc
53
- npm config set global true
59
+ It is much harder to avoid dependency conflicts without nesting
60
+ dependencies. This is fundamental to the way that npm works, and has
61
+ proven to be an extremely successful approach. See ` npm-folders(1) ` for
62
+ more details.
54
63
55
- This is not recommended.
64
+ If you want a package to be installed in one place, and have all your
65
+ programs reference the same copy of it, then use the ` npm link ` command.
66
+ That's what it's for. Install it globally, then link it into each
67
+ program that uses it.
56
68
57
- Many things ** will not work** if you do this. Make sure you read and
58
- understand ` npm-config(1) ` and ` npm-global(1) ` before you complain
59
- about things being broken.
69
+ ## Whatever, I really want the old style 'everything global' style.
60
70
61
- When you realize what a mistake it was, do this to switch back:
71
+ Write your own package manager, then. It's not that hard.
62
72
63
- npm config delete global --local
73
+ npm will not help you do something that is known to be a bad idea.
74
+
75
+ ## Should I check my ` node_modules ` folder into git?
76
+
77
+ Mikeal Rogers answered this question very well:
78
+
79
+ < http://www.mikealrogers.com/posts/nodemodules-in-git.html >
80
+
81
+ tl;dr
82
+
83
+ * Check ` node_modules ` into git for things you ** deploy** , such as
84
+ websites and apps.
85
+ * Do not check ` node_modules ` into git for libraries and modules
86
+ intended to be reused.
87
+ * Use npm to manage dependencies in your dev environment, but not in
88
+ your deployment scripts.
89
+
90
+ ## Is it 'npm' or 'NPM' or 'Npm'?
91
+
92
+ npm should never be capitalized unless it is being displayed in a
93
+ location that is customarily all-caps (such as the title of man pages.)
64
94
65
95
## If 'npm' is an acronym, why is it never capitalized?
66
96
@@ -73,7 +103,7 @@ acronym, and thus incorrectly named.)
73
103
National Association of Pastoral Musicians. You can learn more
74
104
about them at < http://npm.org/ > .
75
105
76
- In software, "NPM" is a non-parametric mapping utility written by
106
+ In software, "NPM" is a Non-Parametric Mapping utility written by
77
107
Chris Rorden. You can analyze pictures of brains with it. Learn more
78
108
about the (capitalized) NPM program at < http://www.cabiatl.com/mricro/npm/ > .
79
109
@@ -186,11 +216,9 @@ Go to <http://admin.npmjs.org/reset>.
186
216
## I get ECONNREFUSED a lot. What's up?
187
217
188
218
Either the registry is down, or node's DNS isn't able to reach out.
189
- This happens a lot if you don't follow * all* the steps in the Cygwin
190
- setup doc.
191
219
192
220
To check if the registry is down, open up
193
- < http://registry.npmjs.org/-/short >
221
+ < http://registry.npmjs.org/ >
194
222
in a web browser. This will also tell you if you are just unable to
195
223
access the internet for some reason.
196
224
0 commit comments