I try to install jsdom such:
$ sudo npm install -g jsdom
# OR
$ sudo npm install jsdom
After some successfull command, the install quickly fails, with the first error message being after the [....]
:
$ sudo npm install jsdom
npm http GET https://registry.npmjs.org/jsdom
npm http 304 https://registry.npmjs.org/jsdom
[....]
> contextify@0.1.7 install /home/yug/Desktop/QGis/WikiAtlas/1_shaded_relief/test/node_modules/jsdom/node_modules/contextify
> node-gyp rebuild
gyp: /home/yug/.node-gyp/0.10.25/common.gypi not found (cwd: /home/yug/Desktop/QGis/WikiAtlas/1_shaded_relief/test/node_modules/jsdom/node_modules/contextify) while reading includes of binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.8.0-35-generic
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/yug/Desktop/QGis/WikiAtlas/1_shaded_relief/test/node_modules/jsdom/node_modules/contextify
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm http 304 https://registry.npmjs.org/domhandler
npm http 304 https://registry.npmjs.org/domelementtype
npm ERR! contextify@0.1.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the contextify@0.1.7 install script.
npm ERR! This is most likely a problem with the contextify package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls contextify
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.8.0-35-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "jsdom"
npm ERR! cwd /home/yug/Desktop/QGis/WikiAtlas/1_shaded_relief/test
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm http 304 https://registry.npmjs.org/qs
npm http 304 https://registry.npmjs.org/entities
....
Hint? This bug also appears for other modules :
$sudo npm install -g topojson
#bug with `contextify@0.1.7 install` error as well.
How to fix that ?
Edit: I tried sudo apt-get remove --purge nodejs npm topojson
then reinstalling via various ways. Even when nodejs
reinstall is successfull, the error stays, so I guess it's rather contextual (node.gyp
? cwd
? ...). Remove/reinstall ways tried :
- ubuntu_setup.sh
- with native outdated url
- with url updated to https://github.com/joyent/node.git,
sudo add-apt-repository ppa:chris-lea/node.js
,- and handmade
git clone https://github.com/joyent/node.git
(trial canceled) - using various other ways :
- way1 : ogoing
As you're finding out from the comments, this is a very common issue. So common, in fact, that the authors of jsdom have documented it right in the README file for the project's git repository.
TL;DR
You need to have a C++ compiler and Python2.7 installed on your machine to install contextify which is a dependency of jsdom. Otherwise, the jsdom install will fail.
From the README on the Github page for jsdom:
Try installing jsdom again after satisfying the requirements mentioned above for your OS, and see if that solves it.
By the way, you are getting the same issue with topojson because it has a dependency on d3 which in turn depends on jsdom, so it is just the same problem installing jsdom. Hope this helps!
--EDIT--
Since it sounds like you're using Ubuntu, I would recommend starting with the following command:
This will install make and g++ and some other tools. This package and Python2.7 is probably about all you'll need to successfully install contextify.
Seems I found a way by carefully deleting all node-related file and folder on my computer.
0. Context: I previously made several unsuccessful console clean-ups, with
followed by ~3 different ways to reinstall
nodejs
. I tried EACH way, from clean-up to reinstall, between 2 & 4 times.1. Terminal purging: Let's first cleaned up my mess the deepest way possible:
Yet, I just noticed that this deep purge does NOT purge/delete installed node modules, which stay persistent.
2. Hand purge: Also, I pushed the purge further with an hand purge for both
nodejs
andnode_modules
. I looked for ALL related folders on my computer, nearer the root (ubuntu:/home/<user>/
) the better. I was careful to delete all previously installed global.../node-modules/
folders, without deleting local modules (specific local installations, which were still working).3. Reinstall: Then the following consoles allowed a clean reinstall:
Afterwhat, my file conversion via npm module
topojson
(depending itself onjsdom
) worked fine :4. Conclusion: I can not identify why, which file/folder deletion allowed the successful
sudo apt-get install nodejs
+sudo npm install -g topojson
reinstall. But thist deep cleanup via mouse and recursive removesudo rm -r [node related folder/file]
definitively unlocked my situation./!\ Be very careful with the
rm -r
recursive remove. /!\Solution 1b: I [suspect][1] the
rm -r /home/<user>/local/lib/node_modules/
to be the key element unlocking the situation. You may list the global (-g
) node_modules, then remove the relevant one(s) (topojson
and/orjsdom
and/ornode-gyp
) specifically, then reinstall it(them).Commands: On ubuntu, try...
Note:
topojson
depends onjsdom
andnpm-gyp
.[1]: not tried, but makes sense according to my diagnostic.