【问题标题】:node-gyp build error mac os x节点gyp构建错误mac os x
【发布时间】:2016-03-16 22:31:34
【问题描述】:

我进行了大量搜索,但在任何地方都找不到我所面临的相同错误。尝试构建 node-gyp 时收到以下错误消息:

node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@3.3.1
gyp info using node@0.10.43 | darwin | x64
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: *** No rule to make target `Release/obj.target/binding/src/binding.o', needed by `Release/binding.node'.  Stop.
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/alexbromage/.nvm/v0.10.43/lib/node_modules/node-   gyp/lib/build.js:276:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Darwin 15.3.0
gyp ERR! command "node" "/Users/alexbromage/.nvm/v0.10.43/bin/node-gyp" "build"
gyp ERR! cwd /Users/alexbromage
gyp ERR! node -v v0.10.43
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 

我的 binding.gyp 文件如下所示:

{
  "targets": [
    {
      "target_name": "binding",
      "sources": [ "src/binding.cc" ]
    }
  ]
}

我认为我的源引用不正确,但我找不到正确设置它的内容。任何帮助表示赞赏

【问题讨论】:

  • src/binding.cc(相对于您的binding.gyp 所在的目录)是否真的存在?
  • 没有。我的 binding.gyp 位于我的主目录中,所以将其更改为 ~/binding.gyp 是否可行?

标签: node.js macos gyp


【解决方案1】:

通常发生此错误时,sources 文件路径不正确。

【讨论】:

  • 我猜是这样,但应该是什么? binding.gyp 文件的位置?
  • 通常您将binding.gyp 放在项目的根目录中,然后拥有src/ 和其他相关路径。使用这种布局,您的sources 应该可以工作(前提是您确实src/ 中有一个名为binding.cc 的文件。
  • 看到这就是为什么我很困惑,因为我根本没有 src/ 并且我已经完全按照安装说明进行操作!
  • 那你的源文件在哪里?只需相应地更改sources 中的路径即可。如果您正在学习教程,那么在您的问题中发布指向该教程的链接也会很有帮助。
  • 所以我已经搜索过了,我的硬盘上没有 src 文件夹或 binding.cc 文件夹。所以我找不到源在哪里。