简体   繁体   中英

Openshift (node.js) fails to install jsdom

Been using Openshift / Node.Js for a while now, mostly problem free. Usually I install (via npm) modules to my local (windows) machine, develop, than git-deploy to Openshift and all goes well.

I recently added the jsdom module (which again works fine locally), but when I git-deploy (no errors on the git push), I get this error when I try to use my app:

.../app-root/runtime/repo/node_modules/jsdom/node_modules/contextify/node_modules/bindings/bindings.js:91
throw err
^
Error: Could not locate the bindings file.

Followed by a list of directories Node attempted to look for it. When I check the remote server for these directories, they are missing (even though they exist on my local machine and were pushed). If I attempt to copy the folders over via ftp, I get this error:

Invalid ELF header

Which I understand is because the contextify module did not build on the server (ie, I copied it over).

Note that my dependencies in my package.json contain "jsdom":"0.1.7".

After some googling, I next tried to manually install the module on the remote server via npm. This produced the following error:

npm http 304 https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/combined-stream
npm http 304 https://registry.npmjs.org/async

> contextify@0.1.7 install /var/lib/openshift/52...52/nodejs/node_modules/jsdom/node_modules/contextify
> node-gyp rebuild

npm http GET https://registry.npmjs.org/assert-plus/0.1.2
npm http GET https://registry.npmjs.org/asn1/0.1.11
npm http GET https://registry.npmjs.org/ctype/0.5.2
npm http 304 https://registry.npmjs.org/ctype/0.5.2
npm http 304 https://registry.npmjs.org/assert-plus/0.1.2
npm http 304 https://registry.npmjs.org/asn1/0.1.11
Traceback (most recent call last):
  File "/opt/rh/nodejs010/root/usr/bin/gyp", line 15, in <module>
    import gyp
ImportError: No module named gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/opt/rh/nodejs010/root/usr/lib/node_modules/node-gyp/lib/configure.js:417:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:784:12)
gyp ERR! System Linux 2.6.32-431.el6oso.bz844450.x86_64
gyp ERR! command "node" "/opt/rh/nodejs010/root/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/lib/openshift/52...52/app-root/runtime/dependencies/nodejs/node_modules/jsdom/node_modules/contextify
gyp ERR! node -v v0.10.5
gyp ERR! node-gyp -v v0.9.5
gyp ERR! not ok

This is where I'm now stuck. It would seem the remote server is missing "gyp", and I have no idea how to solve that. I have the "node-gyp" module installed, and I have read about other npm/openshift issues here , but don't know how to apply them to my problem.

Any help would be greatly appreciated. Thanks in advance!

Per John Peat in question comments, and Ben Parees comment 4 at the bugzilla issue he linked, it seems that the OpenShift Node.js 0.10 cartridge is missing a path to GYP in its shell path variables.

Your set of cartridges may not be providing GYP dependencies. Python may not be available at all. I just confirmed there is no PYTHONPATH environment variable in their Node.Js cartridge, and the system isn't set up to do nmp as user from commandline.

Try declaring jsdom in packages.json, per Redhat docs.

If that fails, or you need a more personal setup, like providing your own Python, then the answer may be to build a cartridge. That would also be an opportunity to move up to Node 0.12 or Io.js.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM