9

I have run into an unusal problem when trying to install pty.js using node:

If I run npm install pty.js I receive this error:

> node-gyp rebuild

  CXX(target) Release/obj.target/pty/src/unix/pty.o
../src/unix/pty.cc:487:10: error: use of undeclared identifier 'openpty'
  return openpty(amaster, aslave, name, (termios *)termp, (winsize *)winp);
         ^
../src/unix/pty.cc:533:10: error: use of undeclared identifier 'forkpty'
  return forkpty(amaster, name, (termios *)termp, (winsize *)winp);
         ^
2 errors generated.
make: *** [Release/obj.target/pty/src/unix/pty.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Darwin 13.3.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/otiswright/Developer/Projects/Web/Hatchway/node_modules/pty.js
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok 
npm ERR! pty.js@0.2.4 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the pty.js@0.2.4 install script.
npm ERR! This is most likely a problem with the pty.js 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 pty.js
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "pty.js"
npm ERR! cwd /Users/otiswright/Developer/Projects/Web/Hatchway
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.5.0-alpha-4
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/otiswright/Developer/Projects/Web/Hatchway/npm-debug.log
npm ERR! not ok code 0

I have node-gyp installed am running OS X with xcode + commandlines installed.

I am not sure where the problem is occurring? Could be dependencies.

jcubic
  • 61,973
  • 54
  • 229
  • 402
Otis Wright
  • 1,980
  • 8
  • 31
  • 53
  • Do you have Python and all the other dependencies of node gyp installed? See here: https://github.com/TooTallNate/node-gyp – David Losert Jul 25 '14 at 07:18
  • 1
    I can install node-gyp? – Otis Wright Jul 25 '14 at 07:33
  • For the Build-Process executed with node-gyp, you need Python and a C/C++-Compiler. Not sure if you already need it for installing, but its definitly a dependency for using the package. – David Losert Jul 25 '14 at 07:52
  • 1
    If i run gcc -v I get: Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin13.3.0 Thread model: posix Does that mean it is installed? – Otis Wright Jul 25 '14 at 08:22

1 Answers1

24

I had the same issue with a different node package devtools-terminal.

The problem is that a header file is configured incorrectly for OSX as explained here.

This is the work around I use:

  1. mkdir /tmp/pty.js
  2. git clone https://github.com/chjj/pty.js.git /tmp/pty.js
  3. vi /tmp/pty.js/src/unix/pty.cc
  4. replace line 39: #include <util.h> with #include "/usr/include/util.h"
  5. npm install -g /tmp/pty.js
  6. and now npm install -g devtools-terminal should work.

This way you fix the issue in pty.js and use your local copy as the dependency for the package you with to install.

Good luck!

SimonW
  • 6,175
  • 4
  • 33
  • 39
  • 1
    I installed npm with homebrew and this fix still resulted in an error when running `npm install -g devtools-terminal`. I removed homebrew's npm (and node apparently disappeared as well, without me having to do it..?) and installed the official node `.pkg` file for OS X, and then this worked (albeit with a warning). – duma Oct 14 '14 at 14:24
  • That's interesting, I'm using brew's `node` which comes with `npm`. Any idea what was wrong? Did you install the same version of `npm`? – SimonW Oct 15 '14 at 12:06
  • @duma I was still having issues after SimonW's suggestion. Issuing 'xcode-select --install' after made things work for me. – StevenTsooo Dec 07 '14 at 00:43
  • Installing `devtools-terminal` now works fine for me without any issues with `pty.js`. Maybe `pty.js` is fixed? – SimonW Feb 24 '15 at 08:11