【问题标题】:Errors installing pty.js (node) on OS X在 OS X 上安装 pty.js(节点)时出错
【发布时间】:2014-07-25 07:05:24
【问题描述】:

我在尝试使用 node 安装 pty.js 时遇到了一个不寻常的问题:

如果我运行 npm install pty.js 我会收到此错误:

> 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

我安装了 node-gyp,运行 OS X 并安装了 xcode + 命令行。

我不确定问题出在哪里?可能是依赖关系。

【问题讨论】:

  • 你是否安装了 Python 和 node gyp 的所有其他依赖项?见这里:github.com/TooTallNate/node-gyp
  • 我可以安装 node-gyp 吗?
  • 对于使用 node-gyp 执行的构建过程,您需要 Python 和 C/C++ 编译器。不确定你是否已经需要它来安装,但它绝对是使用包的依赖项。
  • 如果我运行 gcc -v 我得到: 配置: --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) (基于LLVM 3.4svn) 目标:x86_64-apple-darwin13.3.0 线程模型:posix 是不是意味着已经安装了?

标签: node.js npm pty


【解决方案1】:

我在使用不同的节点包devtools-terminal时遇到了同样的问题。

问题在于OSX 的头文件配置不正确,如here 所述。

这是我使用的解决方法:

  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. 将第 39 行:#include <util.h> 替换为 #include "/usr/include/util.h"
  5. npm install -g /tmp/pty.js
  6. 现在npm install -g devtools-terminal 应该可以工作了。

这样您可以解决pty.js 中的问题,并使用您的本地副本作为您要安装的软件包的依赖项。

祝你好运!

【讨论】:

  • 我用自制软件安装了 npm,这个修复在运行npm install -g devtools-terminal 时仍然导致错误。我删除了 homebrew 的 npm(并且节点显然也消失了,而我不必这样做..?)并为 OS X 安装了官方节点 .pkg 文件,然后这工作(尽管有警告)。
  • 这很有趣,我正在使用 brew 的 node,它带有 npm。知道出了什么问题吗?是否安装了相同版本的npm
  • @duma 在 SimonW 的建议之后我仍然遇到问题。在让事情对我有用之后发出“xcode-select --install”。
  • 安装devtools-terminal 现在对我来说可以正常工作,而pty.js 没有任何问题。也许pty.js 是固定的?
猜你喜欢
  • 2013-05-05
  • 2016-07-22
  • 1970-01-01
  • 1970-01-01
  • 2015-12-10
  • 2011-05-16
  • 2015-01-20
  • 2015-12-06
  • 1970-01-01
相关资源
最近更新 更多