我構建了一個非常簡單的node.js插件,它只打印出字符串「Hello」。當我去建立它使用「節點GYP建」,我得到一個錯誤:使用node-gyp構建node.js插件時出現錯誤
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/hello/hello.o
SOLINK_MODULE(target) Release/hello.node
clang: error: no such file or directory: '「-L/opt/local/lib」'
make: *** [Release/hello.node] 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/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:820:12)
gyp ERR! System Darwin 13.4.0
gyp ERR! command "node" "/usr/local/bin/node-gyp" "build"
gyp ERR! cwd /Users/Kevin/Development/node/sampleaddon
gyp ERR! node -v v0.10.35
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
首先,我去檢查的/ opt/local/lib目錄存在。它的確如此,它充滿了文件。我想這可能是一個權限問題,所以我運行「sudo node-gyp build」。這很好,而且插件的構建沒有錯誤。
所以它看起來像權限相關。所以我看看權限:
Chipmunk:sampleaddon Kevin$ ls -l /opt/local
total 8
drwxr-xr-x 3 root wheel 102 Feb 2 2014 Library
drwxr-xr-x 344 root admin 11696 Mar 13 2014 bin
drwxr-xr-x 7 root admin 238 Feb 2 2014 etc
drwxr-xr-x 70 root admin 2380 Mar 13 2014 include
drwxr-xr-x 240 root admin 8160 Mar 13 2014 lib
drwxr-xr-x 7 root admin 238 Feb 2 2014 libexec
lrwxr-xr-x 1 root admin 9 Feb 2 2014 man -> share/man
drwxr-xr-x 9 root admin 306 Feb 2 2014 sbin
drwxr-xr-x 26 root admin 884 Feb 2 2014 share
drwxr-xr-x 3 root admin 102 Oct 25 2013 var
每個人都可以讀取/ opt/local/lib,所以我不理解問題在這裏。我想構建節點插件,而不必以root身份構建它們。
我使用-g選項安裝了node-gyp,但這是安裝它的正常方法。
有沒有人有一個想法是什麼問題?
編輯:這是binding.gyp文件。
{
"targets" : [
{
"target_name" : "hello",
"sources" : [ "hello.cpp" ]
}
]
}
這裏是什麼樣子,當我運行「命令節點GYP建」,如:
Chipmunk:sampleaddon Kevin$ sudo node-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/hello/hello.o
SOLINK_MODULE(target) Release/hello.node
SOLINK_MODULE(target) Release/hello.node: Finished
gyp info ok
我不知道這是否有差別,但我使用OS X 10.9。 5。
你可以發佈你的'binding.gyp'嗎? – mscdex 2015-02-07 16:48:19
當然。我添加了binding.gyp的內容。 – 2015-02-07 19:10:45