source: node_modules/node-gyp/docs/Error-pre-versions-of-node-cannot-be-installed.md@ 62b2964

finki-main main
Last change on this file since 62b2964 was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 3.8 KB
Line 
1When using `node-gyp` you might see an error like this when attempting to compile/install a node.js native addon:
2
3```
4$ npm install bcrypt
5npm http GET https://registry.npmjs.org/bcrypt/0.7.5
6npm http 304 https://registry.npmjs.org/bcrypt/0.7.5
7npm http GET https://registry.npmjs.org/bindings/1.0.0
8npm http 304 https://registry.npmjs.org/bindings/1.0.0
9
10> bcrypt@0.7.5 install /home/ubuntu/public/song-swap/node_modules/bcrypt
11> node-gyp rebuild
12
13gyp ERR! configure error
14gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
15gyp ERR! stack at install (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:69:16)
16gyp ERR! stack at Object.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:56:37)
17gyp ERR! stack at getNodeDir (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:219:20)
18gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:105:9
19gyp ERR! stack at ChildProcess.exithandler (child_process.js:630:7)
20gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:99:17)
21gyp ERR! stack at maybeClose (child_process.js:730:16)
22gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:5)
23gyp ERR! System Linux 3.5.0-21-generic
24gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
25gyp ERR! cwd /home/ubuntu/public/song-swap/node_modules/bcrypt
26gyp ERR! node -v v0.11.2-pre
27gyp ERR! node-gyp -v v0.9.5
28gyp ERR! not ok
29npm ERR! bcrypt@0.7.5 install: `node-gyp rebuild`
30npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
31npm ERR!
32npm ERR! Failed at the bcrypt@0.7.5 install script.
33npm ERR! This is most likely a problem with the bcrypt package,
34npm ERR! not with npm itself.
35npm ERR! Tell the author that this fails on your system:
36npm ERR! node-gyp rebuild
37npm ERR! You can get their info via:
38npm ERR! npm owner ls bcrypt
39npm ERR! There is likely additional logging output above.
40
41npm ERR! System Linux 3.5.0-21-generic
42npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "bcrypt"
43npm ERR! cwd /home/ubuntu/public/song-swap
44npm ERR! node -v v0.11.2-pre
45npm ERR! npm -v 1.2.18
46npm ERR! code ELIFECYCLE
47npm ERR!
48npm ERR! Additional logging details can be found in:
49npm ERR! /home/ubuntu/public/song-swap/npm-debug.log
50npm ERR! not ok code 0
51```
52
53The main error here is:
54
55```
56Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
57```
58
59This error is caused when you attempt to compile a native addon using a version of node.js with `-pre` at the end of the version number:
60
61``` bash
62$ node -v
63v0.10.4-pre
64```
65
66## How to avoid (the short answer)
67
68To avoid this error completely just use a stable release of node.js. i.e. `v0.10.4`, and __not__ `v0.10.4-pre`.
69
70## How to fix (the long answer)
71
72This error happens because `node-gyp` does not know what header files were used to compile your "pre" version of node, and therefore it needs you to specify the node source code directory path using the `--nodedir` flag.
73
74For example, if I compiled my development ("pre") version of node.js using the source code in `/Users/nrajlich/node`, then I could invoke `node-gyp` like:
75
76``` bash
77$ node-gyp rebuild --nodedir=/Users/nrajlich/node
78```
79
80Or install an native addon through `npm` like:
81
82``` bash
83$ npm install bcrypt --nodedir=/Users/nrajlich/node
84```
85
86### Always use `--nodedir`
87
88__Note:__ This is for advanced users who use `-pre` versions of node more often than tagged releases.
89
90If you're invoking `node-gyp` through `npm`, then you can leverage `npm`'s configuration system and not have to specify the `--nodedir` flag all the time:
91
92``` bash
93$ npm config set nodedir /Users/nrajlich/node
94```
Note: See TracBrowser for help on using the repository browser.