/ / Ubuntu(Amazon EC2インスタンス)にwebsocket-nodeをインストールするにはどうすればよいですか? - node.js、ubuntu、amazon-ec2、websocket、npm

Ubuntu(Amazon EC2インスタンス)にwebsocket-nodeをインストールするにはどうすればいいですか? - node.js、ubuntu、amazon-ec2、websocket、npm

私は「ずっと探していましたが、私が見つけた解決策はどれも助けになっていません」私ができるようにしたいのはただ

npmインストールwebsocket

私がこれについて見つけたほとんどの投稿は、人々がmake、gcc、g ++、またはpythonを欠いていることを示唆していますが、私はこれらすべてを持っています。私のpythonはv2.7.6です。

上記のnpmの失敗を回避するために、私は「

sudo npm --websocket:冗長--nodedir = / home / ubuntu / nodeインストール-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が単にv0.13.0-preノードと互換性がないのではないかと疑問に思いますか?v0.13.0-preを使用すべきですか?

最終的には、同じポート上の同じnode.jsインスタンスからhttp / https&ws / wssを実行できるようにしたいだけです。 websocketノード うまく処理できるようですしかし、wsモジュール(これは普通の古いwsを実行するためにはうまく機能します)の使い方を明確にしていません。

どのようにwsを使用するかについてのどんなポインターもWebSocketで何が悪いのかを理解するのと同じくらい良いでしょう。

回答:

回答№1は1

問題は確かにノードv0.13.0-preとの非互換性であったようです。私はソースとインストールされたノードv0.10.32を手に入れ、そしてしました

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

WebSocketは正しくインストールされています。


回答№2の場合は0

私は手動でnode-gypをインストールして、他のいくつかのnpmインストールを正しく動作させる必要がありました。 グローバルにnode-gypをインストールしなければならなかったかどうかは思い出せませんが…

npm install -g node-gyp
npm install websocket

回答№3の場合は0

Nodeに頼る代わりに。jsを終了するには、リバースプロキシを使用できます。これは多くの点でより簡単な設定です。 Nginxを使用している場合は、次のような設定ファイルが必要です。

server {
listen 443 ssl;
server_name <hostname>;
ssl_certificate <path>/<name>.crt;
ssl_certificate_key <path>/<name>.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;

location / {
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:80;
}
}

これにより、ポート443が開かれ、そのポートへのトラフィックがSSL終了され、そのトラフィックがポート80(Node.jsアプリケーションが実行される場所)に転送されます。