在进行node-build的时候报这个错怎么解决?新手求助
发布于 8 年前 作者 strongwan 8209 次浏览 来自 问答

一个hello.cc,代码 #include <node.h> #include <v8.h>

using namespace v8;

Handle<Value> Method(const Arguments& args) { HandleScope scope; return scope.Close(String::New(“hello,world”)); }

void init(Handle<Object> exports) { exports->Set(String::NewSymbol(“hello”)), FunctionTemplate::New(Method)->GetFunction()); }

NODE_MODULE(hello,init)

一个binding.gyp,代码 { “targets”:[ { “target_name”:“hello”, “sources”:[“hello.cc”] } ] }

一个test.js,代码 var addon = require(’./build/Release/hello’); console.log(addon.hello());

在node-gyp build的时候报这个错误 C:\Users\Administrator\Desktop\hello>node-gyp build gyp info it worked if it ends with ok gyp info using node-gyp@3.3.0 gyp info using node@5.6.0 | win32 | x64 gyp info spawn C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe gyp info spawn args [ ‘build/binding.sln’, gyp info spawn args ‘/clp:Verbosity=minimal’, gyp info spawn args ‘/nologo’, gyp info spawn args ‘/p:Configuration=Release;Platform=x64’ ] 在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。 hello.cc …\hello.cc(6): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int [C:\Users\Administrator\Desktop\hello
build\hello.vcxproj] …\hello.cc(6): error C2143: 语法错误: 缺少“,”(在“&”的前面) [C:\Users\Administrator\Desktop\hello\build\hello.vcx proj] …\hello.cc(7): error C2248: “v8::HandleScope::HandleScope”: 无法访问 protected 成员(在“v8::HandleScope”类中声明) [C:\Users\Administrator\Desktop\hello\build\hello.vcxproj] c:\users\administrator.node-gyp\5.6.0\include\node\v8.h(889): note: 参见“v8::HandleScope::HandleScope” 的声明 c:\users\administrator.node-gyp\5.6.0\include\node\v8.h(873): note: 参见“v8::HandleScope”的声明 …\hello.cc(8): error C2039: “Close”: 不是“v8::HandleScope”的成员 [C:\Users\Administrator\Desktop\hello\buil d\hello.vcxproj] c:\users\administrator.node-gyp\5.6.0\include\node\v8.h(873): note: 参见“v8::HandleScope”的声明 …\hello.cc(8): error C2039: “New”: 不是“v8::String”的成员 [C:\Users\Administrator\Desktop\hello\build\hello .vcxproj] c:\users\administrator.node-gyp\5.6.0\include\node\v8.h(2078): note: 参见“v8::String”的声明 …\hello.cc(8): error C3861: “New”: 找不到标识符 [C:\Users\Administrator\Desktop\hello\build\hello.vcxproj] …\hello.cc(12): error C2039: “NewSymbol”: 不是“v8::String”的成员 [C:\Users\Administrator\Desktop\hello\buil d\hello.vcxproj] c:\users\administrator.node-gyp\5.6.0\include\node\v8.h(2078): note: 参见“v8::String”的声明 …\hello.cc(12): error C3861: “NewSymbol”: 找不到标识符 [C:\Users\Administrator\Desktop\hello\build\hello.vcx proj] …\hello.cc(13): error C2664: “v8::Localv8::FunctionTemplate v8::FunctionTemplate::New(v8::Isolate *, v8::FunctionCallback,v8::Localv8::Value,v8::Localv8::Signature,int)”: 无法将参数 1 从“v8::Local<v8::Value

(__cdecl *)(const int)”转换为“v8::Isolate *” [C:\Users\Administrator\Desktop\hello\build\hello.vcxproj] …\hello.cc(13): note: 没有使该转换得以执行的上下文 …\hello.cc(13): error C2227: “->GetFunction”的左边必须指向类/结构/联合/泛型类型 [C:\Users\Administrator\Desktop\hello
build\hello.vcxproj] …\hello.cc(13): error C2059: 语法错误:“)” [C:\Users\Administrator\Desktop\hello\build\hello.vcxproj] gyp ERR! build error gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Users\Administrator\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:276:23) gyp ERR! stack at emitTwo (events.js:100:13) gyp ERR! stack at ChildProcess.emit (events.js:185:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) gyp ERR! System Windows_NT 10.0.10586 gyp ERR! command “C:\Program Files\nodejs\node.exe” “C:\Users\Administrator\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js” "build" gyp ERR! cwd C:\Users\Administrator\Desktop\hello gyp ERR! node -v v5.6.0 gyp ERR! node-gyp -v v3.3.0 gyp ERR! not ok

请问怎么解决啊?

2 回复

楼主 我也是这种情况 你解决了吗 我的环境是win7 64位 vs2010 1.jpg

我也出了。。。

回到顶部