JacksonTian / diveintonode_examples

《深入浅出Node.js》的相关代码

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

好多例子在最新的环境都运行不了。

itlijunjie opened this issue · comments

现在已经是2015年了,而这本书也应该出新版了。

是本来就运行不了 还是最新环境运行不了?

就环境没试过啊?我是个初学者,下载的都是新环境。

这个例子我试了下node-gyp build 不成功啊?

lijunjiedeMacBook-Pro:addon ljj$ cd /Volumes/soft/github_repository/diveintonode_examples/02/addon
lijunjiedeMacBook-Pro:addon ljj$ node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@3.1.0
gyp info using node@4.2.2 | darwin | x64
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Volumes/soft/github_repository/diveintonode_examples/02/addon/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/ljj/.node-gyp/4.2.2/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/ljj/.node-gyp/4.2.2',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=node.lib',
gyp info spawn args '-Dmodule_root_dir=/Volumes/soft/github_repository/diveintonode_examples/02/addon',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
2015-11-20 15:35:49.828 xcodebuild[9117:236705] [MT] DVTPlugInManager: Required plug-in compatibility UUID 7265231C-39B4-402C-89E1-16167C4CC990 for KSImageNamed.ideplugin (com.ksuther.KSImageNamed) not present
gyp info ok
lijunjiedeMacBook-Pro:addon ljj$ node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@3.1.0
gyp info using node@4.2.2 | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/hello/src/hello.o
../src/hello.cc http://hello.cc/:6:30: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
Handle SayHello(const Arguments& args) {
^~~~~~~~~
v8::internal::Arguments
/Users/ljj/.node-gyp/4.2.2/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
../src/hello.cc http://hello.cc/:7:15: error: calling a protected constructor of class 'v8::HandleScope'
HandleScope scope;
^
/Users/ljj/.node-gyp/4.2.2/include/node/v8.h:885:13: note: declared protected here
V8_INLINE HandleScope() {}
^
../src/hello.cc http://hello.cc/:8:16: error: no member named 'Close' in 'v8::HandleScope'
return scope.Close(String::New("Hello world!"));
~~~~~ ^
../src/hello.cc http://hello.cc/:8:30: error: no member named 'New' in 'v8::String'
return scope.Close(String::New("Hello world!"));
~~~~~~~~^
../src/hello.cc http://hello.cc/:13:68: error: cannot initialize a parameter of type 'v8::Isolate *' with an lvalue of type
'Handlev8::Value (const v8::internal::Arguments &)'
target->Set(String::NewSymbol("sayHello"), FunctionTemplate::New(SayHello)->GetFunction());
^~~~~~~~
/Users/ljj/.node-gyp/4.2.2/include/node/v8.h:4350:16: note: passing argument to parameter 'isolate' here
Isolate* isolate, FunctionCallback callback = 0,
^
../src/hello.cc http://hello.cc/:13:23: error: no member named 'NewSymbol' in 'v8::String'
target->Set(String::NewSymbol("sayHello"), FunctionTemplate::New(SayHello)->GetFunction());
~~~~~~~~^
In file included from ../src/hello.cc http://hello.cc/:1:
In file included from /Users/ljj/.node-gyp/4.2.2/include/node/node.h:42:
/Users/ljj/.node-gyp/4.2.2/include/node/v8.h:327:9: error: cannot initialize a member subobject of type
'v8::FunctionTemplate *' with an lvalue of type 'const char *'
: val_(that) {}
^ ~~~~
../src/hello.cc http://hello.cc/:8:34: note: in instantiation of function template specialization
'v8::Localv8::FunctionTemplate::Local' requested here
return scope.Close(String::New("Hello world!"));
^
7 errors generated.
make: *** [Release/obj.target/hello/src/hello.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/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.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/bin/node-gyp" "build"
gyp ERR! cwd /Volumes/soft/github_repository/diveintonode_examples/02/addon
gyp ERR! node -v v4.2.2
gyp ERR! node-gyp -v v3.1.0
gyp ERR! not ok
lijunjiedeMacBook-Pro:addon ljj$

在 2015年11月20日,上午10:28,Jackson Tian <notifications@github.com mailto:notifications@github.com> 写道:

是本来就运行不了 还是最新环境运行不了?


Reply to this email directly or view it on GitHub #3 (comment).

Addon 确实是旧了。

在 2015年11月20日,下午3:39,Li Junjie notifications@github.com 写道:

就环境没试过啊?我是个初学者,下载的都是新环境。

这个例子我试了下node-gyp build 不成功啊?

lijunjiedeMacBook-Pro:addon ljj$ cd /Volumes/soft/github_repository/diveintonode_examples/02/addon
lijunjiedeMacBook-Pro:addon ljj$ node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@3.1.0
gyp info using node@4.2.2 | darwin | x64
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Volumes/soft/github_repository/diveintonode_examples/02/addon/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/ljj/.node-gyp/4.2.2/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/ljj/.node-gyp/4.2.2',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=node.lib',
gyp info spawn args '-Dmodule_root_dir=/Volumes/soft/github_repository/diveintonode_examples/02/addon',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
2015-11-20 15:35:49.828 xcodebuild[9117:236705] [MT] DVTPlugInManager: Required plug-in compatibility UUID 7265231C-39B4-402C-89E1-16167C4CC990 for KSImageNamed.ideplugin (com.ksuther.KSImageNamed) not present
gyp info ok
lijunjiedeMacBook-Pro:addon ljj$ node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@3.1.0
gyp info using node@4.2.2 | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/hello/src/hello.o
../src/hello.cc http://hello.cc/:6:30: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
Handle SayHello(const Arguments& args) {
^~~~~~~~~
v8::internal::Arguments
/Users/ljj/.node-gyp/4.2.2/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
^
../src/hello.cc http://hello.cc/:7:15: error: calling a protected constructor of class 'v8::HandleScope'
HandleScope scope;
^
/Users/ljj/.node-gyp/4.2.2/include/node/v8.h:885:13: note: declared protected here
V8_INLINE HandleScope() {}
^
../src/hello.cc http://hello.cc/:8:16: error: no member named 'Close' in 'v8::HandleScope'
return scope.Close(String::New("Hello world!"));

../src/hello.cc <http://hello.cc/>:8:30: error: no member named 'New' in 'v8::String'
return scope.Close(String::New("Hello world!"));
~~~~~~~~^
../src/hello.cc <http://hello.cc/>:13:68: error: cannot initialize a parameter of type 'v8::Isolate *' with an lvalue of type
'Handle<v8::Value> (const v8::internal::Arguments &)'
target->Set(String::NewSymbol("sayHello"), FunctionTemplate::New(SayHello)->GetFunction());
^~~~~~~~
/Users/ljj/.node-gyp/4.2.2/include/node/v8.h:4350:16: note: passing argument to parameter 'isolate' here
Isolate* isolate, FunctionCallback callback = 0,
^
../src/hello.cc <http://hello.cc/>:13:23: error: no member named 'NewSymbol' in 'v8::String'
target->Set(String::NewSymbol("sayHello"), FunctionTemplate::New(SayHello)->GetFunction());
~~~~~~~~^
In file included from ../src/hello.cc <http://hello.cc/>:1:
In file included from /Users/ljj/.node-gyp/4.2.2/include/node/node.h:42:
/Users/ljj/.node-gyp/4.2.2/include/node/v8.h:327:9: error: cannot initialize a member subobject of type
'v8::FunctionTemplate *' with an lvalue of type 'const char *'
: val_(that) {}
^ ~~~~
../src/hello.cc <http://hello.cc/>:8:34: note: in instantiation of function template specialization
'v8::Local<v8::FunctionTemplate>::Local<const char>' requested here
return scope.Close(String::New("Hello world!"));
^
7 errors generated.
make: *** [Release/obj.target/hello/src/hello.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/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.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/bin/node-gyp" "build"
gyp ERR! cwd /Volumes/soft/github_repository/diveintonode_examples/02/addon
gyp ERR! node -v v4.2.2
gyp ERR! node-gyp -v v3.1.0
gyp ERR! not ok 
lijunjiedeMacBook-Pro:addon ljj$ 


> 在 2015年11月20日,上午10:28,Jackson Tian <notifications@github.com <mailto:notifications@github.com>> 写道:
> 
> 是本来就运行不了 还是最新环境运行不了?
> 
> —
> Reply to this email directly or view it on GitHub <https://github.com/JacksonTian/diveintonode_examples/issues/3#issuecomment-158261195>.
> 

—
Reply to this email directly or view it on GitHub <https://github.com/JacksonTian/diveintonode_examples/issues/3#issuecomment-158312397>.