gpt4 book ai didi

node.js - 如何在 Ubuntu(Amazon EC2 实例)上安装 websocket-node?

转载 作者:行者123 更新时间:2023-12-04 19:19:22 25 4
gpt4 key购买 nike

我一直在寻找,但我找到的解决方案都没有帮助。我想做的就是

npm 安装 websocket

我在此找到的大多数帖子都表明人们缺少 make、gcc、g++ 或 python,但我拥有所有这些。我的python是v2.7.6。

为了解决上述 npm 失败的问题,我已经做到了,

sudo npm --websocket:verbose --nodedir=/home/ubuntu/node install -g websocket

但是当我尝试时,我得到:

ubuntu@ip-172-31-20-33:~$ sudo npm --websocket:verbose --nodedir=/home/ubuntu/node install -g websocket

> websocket@1.0.8 install /usr/local/lib/node_modules/websocket
> node install.js

[websocket v1.0.8] Attempting to compile native extensions.
child_process: customFds option is deprecated, use stdio instead.
make: Entering directory `/usr/local/lib/node_modules/websocket/build'
CXX(target) Release/obj.target/validation/src/validation.o
../src/validation.cc:117:34: error: ‘Arguments’ does not name a type
static Handle<Value> New(const Arguments& args)
^
../src/validation.cc:117:45: error: ISO C++ forbids declaration of ‘args’ with no type [-fpermissive]
static Handle<Value> New(const Arguments& args)
^
../src/validation.cc:125:42: error: ‘Arguments’ does not name a type
static Handle<Value> IsValidUTF8(const Arguments& args)
^
../src/validation.cc:125:53: error: ISO C++ forbids declaration of ‘args’ with no type [-fpermissive]
static Handle<Value> IsValidUTF8(const Arguments& args)
^
In file included from ../src/validation.cc:8:0:
/home/ubuntu/node/deps/v8/include/v8.h: In static member function ‘static void Validation::Initialize(v8::Handle<v8::Object>)’:
/home/ubuntu/node/deps/v8/include/v8.h:816:13: error: ‘v8::HandleScope::HandleScope()’ is protected
V8_INLINE HandleScope() {}
^
../src/validation.cc:108:17: error: within this context
HandleScope scope;
^
../src/validation.cc:109:58: error: no matching function for call to ‘v8::FunctionTemplate::New(v8::Handle<v8::Value> (&)(const int&))’
Local<FunctionTemplate> t = FunctionTemplate::New(New);
^
../src/validation.cc:109:58: note: candidate is:
In file included from ../src/validation.cc:8:0:
/home/ubuntu/node/deps/v8/include/v8.h:3434:34: note: static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::Isolate*, v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)
static Local<FunctionTemplate> New(
^
/home/ubuntu/node/deps/v8/include/v8.h:3434:34: note: no known conversion for argument 1 from ‘v8::Handle<v8::Value>(const int&)’ to ‘v8::Isolate*’
../src/validation.cc:111:77: error: no matching function for call to ‘NODE_SET_METHOD(v8::Local<v8::Function>, const char [12], v8::Handle<v8::Value> (&)(const int&))’
NODE_SET_METHOD(t->GetFunction(), "isValidUTF8", Validation::IsValidUTF8);
^
../src/validation.cc:111:77: note: candidate is:
In file included from ../src/validation.cc:9:0:
/home/ubuntu/node/src/node.h:211:13: note: template<class TypeName> void node::NODE_SET_METHOD(const TypeName&, const char*, v8::FunctionCallback)
inline void NODE_SET_METHOD(const TypeName& recv,
^
/home/ubuntu/node/src/node.h:211:13: note: template argument deduction/substitution failed:
../src/validation.cc:111:77: note: cannot convert ‘Validation::IsValidUTF8’ (type ‘v8::Handle<v8::Value>(const int&)’) to type ‘v8::FunctionCallback {aka void (*)(const v8::FunctionCallbackInfo<v8::Value>&)}’
NODE_SET_METHOD(t->GetFunction(), "isValidUTF8", Validation::IsValidUTF8);
^
../src/validation.cc:112:17: error: ‘NewSymbol’ is not a member of ‘v8::String’
target->Set(String::NewSymbol("Validation"), t->GetFunction());
^
In file included from ../src/validation.cc:8:0:
/home/ubuntu/node/deps/v8/include/v8.h: In static member function ‘static v8::Handle<v8::Value> Validation::New(const int&)’:
/home/ubuntu/node/deps/v8/include/v8.h:816:13: error: ‘v8::HandleScope::HandleScope()’ is protected
V8_INLINE HandleScope() {}
^
../src/validation.cc:119:17: error: within this context
HandleScope scope;
^
../src/validation.cc:121:27: error: request for member ‘This’ in ‘args’, which is of non-class type ‘const int’
validation->Wrap(args.This());
^
../src/validation.cc:122:17: error: request for member ‘This’ in ‘args’, which is of non-class type ‘const int’
return args.This();
^
In file included from ../src/validation.cc:8:0:
/home/ubuntu/node/deps/v8/include/v8.h: In static member function ‘static v8::Handle<v8::Value> Validation::IsValidUTF8(const int&)’:
/home/ubuntu/node/deps/v8/include/v8.h:816:13: error: ‘v8::HandleScope::HandleScope()’ is protected
V8_INLINE HandleScope() {}
^
../src/validation.cc:127:17: error: within this context
HandleScope scope;
^
../src/validation.cc:128:36: error: invalid types ‘const int[int]’ for array subscript
if (!Buffer::HasInstance(args[0])) {
^
../src/validation.cc:129:46: error: ‘New’ is not a member of ‘v8::String’
return ThrowException(Exception::Error(String::New("First argument needs to be a buffer")));
^
../src/validation.cc:129:97: error: ‘ThrowException’ was not declared in this scope
return ThrowException(Exception::Error(String::New("First argument needs to be a buffer")));
^
../src/validation.cc:131:38: error: invalid types ‘const int[int]’ for array subscript
Local<Object> buffer_obj = args[0]->ToObject();
^
../src/validation.cc:134:67: error: ‘class v8::HandleScope’ has no member named ‘Close’
return is_valid_utf8(buffer_length, buffer_data) == 1 ? scope.Close(True()) : scope.Close(False());
^
../src/validation.cc:134:78: error: too few arguments to function ‘v8::Handle<v8::Boolean> v8::True(v8::Isolate*)’
return is_valid_utf8(buffer_length, buffer_data) == 1 ? scope.Close(True()) : scope.Close(False());
^
In file included from ../src/validation.cc:8:0:
/home/ubuntu/node/deps/v8/include/v8.h:6526:17: note: declared here
Handle<Boolean> True(Isolate* isolate) {
^
../src/validation.cc:134:89: error: ‘class v8::HandleScope’ has no member named ‘Close’
return is_valid_utf8(buffer_length, buffer_data) == 1 ? scope.Close(True()) : scope.Close(False());
^
../src/validation.cc:134:101: error: too few arguments to function ‘v8::Handle<v8::Boolean> v8::False(v8::Isolate*)’
return is_valid_utf8(buffer_length, buffer_data) == 1 ? scope.Close(True()) : scope.Close(False());
^
In file included from ../src/validation.cc:8:0:
/home/ubuntu/node/deps/v8/include/v8.h:6535:17: note: declared here
Handle<Boolean> False(Isolate* isolate) {
^
/home/ubuntu/node/deps/v8/include/v8.h: In function ‘void init(v8::Handle<v8::Object>)’:
/home/ubuntu/node/deps/v8/include/v8.h:816:13: error: ‘v8::HandleScope::HandleScope()’ is protected
V8_INLINE HandleScope() {}
^
../src/validation.cc:140:15: error: within this context
HandleScope scope;
^
make: *** [Release/obj.target/validation/src/validation.o] Error 1
make: Leaving directory `/usr/local/lib/node_modules/websocket/build'
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/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1059:12)
gyp ERR! System Linux 3.13.0-36-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/websocket
gyp ERR! node -v v0.13.0-pre
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
[websocket v1.0.8]
Native code compile failed!!
Please note that this module DOES NOT REQUIRE the native components
and will still work without them, though not quite as efficiently.

On Windows, native extensions require Visual Studio and Python.
On Unix, native extensions require Python, make and a C++ compiler.
Start npm with --websocket:verbose to show compilation output (if any).
websocket@1.0.8 /usr/local/lib/node_modules/websocket

有人知道发生了什么吗?

我注意到 websocket-node 更新已经有一段时间了。我想知道 websocket-node 是否与 node v0.13.0-pre 不兼容?我什至应该使用 v0.13.0-pre 吗?

最终,我只想能够从同一端口上的同一 node.js 实例运行 http/https 和 ws/wss。 websocket Node seems able to handle fine ,但不清楚如何处理 ws 模块(它适用于只做普通的旧 ws)。

任何有关如何使用 ws 的指示都与找出 websocket 出了什么问题一样好。

最佳答案

看来问题确实是与 Node v0.13.0-pre 不兼容。我得到了源代码并安装了 Node v0.10.32 然后做了

sudo npm --websocket:verbose --nodedir=/home/ubuntu/node-v0.10.32 install -g websocket

和 websocket 安装正确。

关于node.js - 如何在 Ubuntu(Amazon EC2 实例)上安装 websocket-node?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26090511/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com