node.jsでcurlを使おうと調べていたところnode-curlというリポジトリを見つけました。
https://github.com/jiangmiao/node-curl
しかし、これをインストールしたところエラーが発生しました。
# % npm install --save node-curl
> node-curl@0.3.3 install /Users/syossan27/hoge/node_modules/node-curl
> sh src/generate_curl_options_list.sh && (node-gyp rebuild || node-waf configure build)
extract constants from /usr/include/curl/curl.h
generate src/integer_options.h
generate src/string_options.h
generate src/integer_infos.h
generate src/string_infos.h
generate src/double_infos.h
CXX(target) Release/obj.target/node-curl/src/node-curl.o
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:178:43: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> close(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:265:45: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> getinfo(const v8::Arguments &args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:278:49: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> getinfo_int(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:283:49: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> getinfo_str(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:288:52: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> getinfo_double(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:293:51: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> getinfo_slist(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:330:48: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> setopt_int(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:335:48: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> setopt_str(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:347:50: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> setopt_slist(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:355:53: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> setopt_httppost(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:426:41: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> New(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:433:45: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> process(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:476:45: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> perform(const v8::Arguments & args)
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:496:47: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
static v8::Handle<v8::Value> get_count(const v8::Arguments & args )
^~~~~~~~~~~~~
v8::internal::Arguments
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:124:11: error: no member named 'AdjustAmountOfExternalAllocatedMemory' in 'v8::V8'
v8::V8::AdjustAmountOfExternalAllocatedMemory(2*4096);
~~~~~~~~^
../src/node-curl.h:125:11: error: no member named 'SetPointerInInternalField' in 'v8::Object'; did you mean 'SetAlignedPointerInInternalField'?
object->SetPointerInInternalField(0, this);
^~~~~~~~~~~~~~~~~~~~~~~~~
SetAlignedPointerInInternalField
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:2793:8: note: 'SetAlignedPointerInInternalField' declared here
void SetAlignedPointerInInternalField(int index, void* value);
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:126:40: error: 'New' is a private member of 'v8::PersistentBase<v8::Object>'
handle = v8::Persistent<v8::Object>::New(object);
^
/Users/syossan27/.node-gyp/5.3.0/include/node/v8.h:643:23: note: declared private here
V8_INLINE static T* New(Isolate* isolate, T* that);
^
In file included from ../src/node-curl.cc:1:
../src/node-curl.h:126:12: error: too few arguments to function call, expected 2, have 1; did you mean '::NodeCurl::New'?
handle = v8::Persistent<v8::Object>::New(object);
^~
::NodeCurl::New
../src/node-curl.h:426:31: note: '::NodeCurl::New' declared here
static v8::Handle<v8::Value> New(const v8::Arguments & args)
^
../src/node-curl.h:127:10: error: no member named 'MakeWeak' in 'v8::Persistent<v8::Object, v8::NonCopyablePersistentTraits<v8::Object> >'
handle.MakeWeak(this, destructor);
~~~~~~ ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/node-curl/src/node-curl.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/syossan27/.nvm/versions/node/v5.3.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.2.0
gyp ERR! command "/Users/syossan27/.nvm/versions/node/v5.3.0/bin/node" "/Users/syossan27/.nvm/versions/node/v5.3.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/syossan27/hoge/node_modules/node-curl
gyp ERR! node -v v5.3.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
sh: node-waf: command not found
npm WARN EPACKAGEJSON hoge@1.0.0 No description
npm WARN EPACKAGEJSON hoge@1.0.0 No repository field.
npm ERR! Darwin 15.2.0
npm ERR! argv "/Users/syossan27/.nvm/versions/node/v5.3.0/bin/node" "/Users/syossan27/.nvm/versions/node/v5.3.0/bin/npm" "install" "--save" "node-curl"
npm ERR! node v5.3.0
npm ERR! npm v3.3.12
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! node-curl@0.3.3 install: `sh src/generate_curl_options_list.sh && (node-gyp rebuild || node-waf configure build)`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the node-curl@0.3.3 install script 'sh src/generate_curl_options_list.sh && (node-gyp rebuild || node-waf configure build)'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-curl package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! sh src/generate_curl_options_list.sh && (node-gyp rebuild || node-waf configure build)
npm ERR! You can get their info via:
npm ERR! npm owner ls node-curl
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/syossan27/hoge/npm-debug.log
ふーむ、と思いissuesを眺めているとこんなものが。
Compiler error with Node v0.12.0 #38
どうもV8周りのコールバック関数の扱いがnodeのバージョンアップによって変わった様子。
そして、node-curlをforkして新たにV8の部分を書き直した方がいました。
https://github.com/jiangmiao/node-curl/issues/38#issuecomment-96231726
その方が新たに作ったnode-libcurl
https://github.com/JCMais/node-libcurl
こちらだと特にエラーが発生すること無く使うことができました。
困っている方はこちらのnode-libcurlを使ってみてください。