|
1 |
| -`npm` bundles its own, internal, copy of `node-gyp`. This internal copy is independent of any globally installed copy of node-gyp that you may have installed via `npm install -g node-gyp`. |
| 1 | +`npm` bundles its own, internal, copy of `node-gyp`. This internal copy is independent of any globally installed copy of node-gyp that |
| 2 | +you may have installed via `npm install -g node-gyp`. |
2 | 3 |
|
3 |
| -This means that while `node-gyp` doesn't get installed into your `$PATH` by default, npm still keeps its own copy to invoke when you attempt to `npm install` a native addon. |
| 4 | +This means that while `node-gyp` doesn't get installed into your `$PATH` by default, npm still keeps its own copy to invoke when you |
| 5 | +attempt to `npm install` a native add-on. |
4 | 6 |
|
5 |
| -Sometimes, you may need to update npm's internal node-gyp to a newer version than what is installed. A simple `npm install -g node-gyp` _won't_ do the trick since npm will still continue to use its internal copy over the global one. |
| 7 | +Sometimes, you may need to update npm's internal node-gyp to a newer version than what is installed. A simple `npm install -g node-gyp` |
| 8 | +_won't_ do the trick since npm will still continue to use its internal copy over the global one. |
6 | 9 |
|
7 | 10 | So instead:
|
8 | 11 |
|
9 | 12 | ## Linux, Mac OS X, Solaris, etc.
|
10 | 13 |
|
11 | 14 | Unix is easy. Just run the following command. Use `sudo` if necessary.
|
12 |
| - |
13 |
| -``` bash |
14 |
| -$ [sudo] npm explore npm -g -- npm install node-gyp@latest |
| 15 | +```bash |
| 16 | +$ [sudo] npm explore npm/node_modules/npm-lifecycle -g -- npm install node-gyp@latest |
15 | 17 | ```
|
16 | 18 |
|
17 | 19 | ## Windows
|
18 | 20 |
|
19 |
| -Windows is a bit tricker, since `npm` gets installed to the "Program Files" directory, which needs admin privileges in order to modify on current Windows. Therefore, run the following commands __inside a `cmd.exe` started with "Run as Administrator"__: |
| 21 | +Windows is a bit trickier, since `npm` might be installed to the "Program Files" directory, which needs admin privileges in order to |
| 22 | +modify on current Windows. Therefore, run the following commands __inside a `cmd.exe` started with "Run as Administrator"__: |
20 | 23 |
|
21 | 24 | First we need to find the location of `node`. If you don't already know the location that `node.exe` got installed to, then run:
|
22 |
| - |
23 |
| -``` bash |
| 25 | +```bash |
24 | 26 | $ npm install -g which
|
25 | 27 | $ which node
|
26 | 28 | ```
|
27 | 29 |
|
28 | 30 | As an alternative to the above, those on Windows Server 2003 and later (this includes Windows 7) can run:
|
29 |
| - |
30 |
| -``` bash |
| 31 | +```bash |
31 | 32 | $ where node
|
32 | 33 | ```
|
33 | 34 |
|
34 | 35 | Now `cd` to the directory that `node.exe` is contained in, and with `node_modules\npm` at the end. i.e.:
|
35 |
| - |
36 |
| -``` bash |
| 36 | +```bash |
37 | 37 | $ cd "C:\Program Files\nodejs\node_modules\npm"
|
38 | 38 | ```
|
39 | 39 |
|
40 |
| -Now you can finally run: |
| 40 | +Now you can run: |
| 41 | +```bash |
| 42 | +$ npm install node-gyp@latest |
| 43 | +``` |
41 | 44 |
|
42 |
| -``` bash |
43 |
| -$ npm install -g node-gyp@latest |
| 45 | +Now `cd` to the `npm-lifecycle` directory: |
| 46 | +```bash |
| 47 | +$ cd node_modules\npm-lifecycle |
44 | 48 | ```
|
45 | 49 |
|
46 |
| -note: i found that the -g on windows 7 is not correct. It gets installed in C:\Users\<name>\AppData\Roaming\npm\node_modules\gyp which is not the directory where node is installed C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\... |
| 50 | +Now you can finally run (again): |
| 51 | +```bash |
| 52 | +$ npm install node-gyp@latest |
| 53 | +``` |
0 commit comments