2017-05-08 118 views
0

我使用下面的模塊具有服務器的NodeJS:無法在本地更新或安裝mongojs模塊的NodeJS

enter image description here

服務器用4.X的NodeJS開發LTS和工作得很好。 但是我正在嘗試升級到NodeJS 6.X LTS,看起來mongojs模塊我使用它不再與此版本兼容。 不幸的是,我無法更新它或安裝最新版本。

我在Windows和MacOS上都試過,結果是一樣的。

如果我嘗試npm install mongojs在MacOS我得到這個:

Last login: Mon May 8 12:55:51 on ttys003 
Bogdans-MBP:mongojs bogdangheorghe$ ls 
Bogdans-MBP:mongojs bogdangheorghe$ sudo npm install mongojs 
Password: 
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue 

> [email protected] install /Users/bogdangheorghe/Workspace/Servers/RCPHelper_Server/RCPHelper_Server/node_modules/java 
> node-gyp rebuild 

    CXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o 
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:342:68: error: too many arguments to function call, expected at most 2, have 4 
    return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv); 
      ~~~~~~~~~~~~~~~~~~          ^~~~~~~~~~ 
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:4833:3: note: 'New' declared here 
    static Local<Signature> New(
^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:397:32: warning: 'CompileUnbound' is deprecated [-Wdeprecated-declarations] 
    return v8::ScriptCompiler::CompileUnbound(
          ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:1334:45: note: 'CompileUnbound' has been explicitly marked deprecated here 
         Local<UnboundScript> CompileUnbound(
              ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:406:32: warning: 'CompileUnbound' is deprecated [-Wdeprecated-declarations] 
    return v8::ScriptCompiler::CompileUnbound(
          ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:1334:45: note: 'CompileUnbound' has been explicitly marked deprecated here 
         Local<UnboundScript> CompileUnbound(
              ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:412:31: warning: 'New' is deprecated [-Wdeprecated-declarations] 
    return v8::BooleanObject::New(value).As<v8::BooleanObject>(); 
          ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:4008:56: note: 'New' has been explicitly marked deprecated here 
    V8_DEPRECATED("Pass an isolate", static Local<Value> New(bool value)); 
                ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:424:3: error: redefinition of 'NanNew' 
    NanNew<v8::StringObject, v8::Handle<v8::String> >(
^
../../nan/nan.h:417:3: note: previous definition is here 
    NanNew<v8::StringObject, v8::Local<v8::String> >(
^
../../nan/nan.h:442:36: error: redefinition of 'NanNew' 
    NAN_INLINE v8::Local<v8::RegExp> NanNew(
           ^
../../nan/nan.h:436:36: note: previous definition is here 
    NAN_INLINE v8::Local<v8::RegExp> NanNew(
           ^
../../nan/nan.h:454:36: error: redefinition of 'NanNew' 
    NAN_INLINE v8::Local<v8::RegExp> NanNew(
           ^
../../nan/nan.h:448:36: note: previous definition is here 
    NAN_INLINE v8::Local<v8::RegExp> NanNew(
           ^
../../nan/nan.h:462:42: warning: 'ToUint32' is deprecated [-Wdeprecated-declarations] 
     v8::Isolate::GetCurrent(), val)->ToUint32(); 
             ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:8196:22: note: 'ToUint32' has been explicitly marked deprecated here 
Local<Uint32> Value::ToUint32() const { 
        ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:468:42: warning: 'ToUint32' is deprecated [-Wdeprecated-declarations] 
     v8::Isolate::GetCurrent(), val)->ToUint32(); 
             ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:8196:22: note: 'ToUint32' has been explicitly marked deprecated here 
Local<Uint32> Value::ToUint32() const { 
        ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:473:60: warning: 'ToInt32' is deprecated [-Wdeprecated-declarations] 
    return v8::Int32::New(v8::Isolate::GetCurrent(), val)->ToInt32(); 
                 ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:8202:21: note: 'ToInt32' has been explicitly marked deprecated here 
Local<Int32> Value::ToInt32() const { 
        ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:478:60: warning: 'ToInt32' is deprecated [-Wdeprecated-declarations] 
    return v8::Int32::New(v8::Isolate::GetCurrent(), val)->ToInt32(); 
                 ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:8202:21: note: 'ToInt32' has been explicitly marked deprecated here 
Local<Int32> Value::ToInt32() const { 
        ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:518:24: warning: 'NewFromOneByte' is deprecated [-Wdeprecated-declarations] 
    return v8::String::NewFromOneByte(
        ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:2334:21: note: 'NewFromOneByte' has been explicitly marked deprecated here 
     Local<String> NewFromOneByte(Isolate* isolate, const uint8_t* data, 
        ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:529:24: warning: 'NewFromOneByte' is deprecated [-Wdeprecated-declarations] 
    return v8::String::NewFromOneByte(
        ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:2334:21: note: 'NewFromOneByte' has been explicitly marked deprecated here 
     Local<String> NewFromOneByte(Isolate* isolate, const uint8_t* data, 
        ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:538:24: warning: 'NewFromOneByte' is deprecated [-Wdeprecated-declarations] 
    return v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), arg); 
        ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:2334:21: note: 'NewFromOneByte' has been explicitly marked deprecated here 
     Local<String> NewFromOneByte(Isolate* isolate, const uint8_t* data, 
        ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:544:24: warning: 'NewFromOneByte' is deprecated [-Wdeprecated-declarations] 
    return v8::String::NewFromOneByte(v8::Isolate::GetCurrent(), arg); 
        ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:2334:21: note: 'NewFromOneByte' has been explicitly marked deprecated here 
     Local<String> NewFromOneByte(Isolate* isolate, const uint8_t* data, 
        ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:619:24: warning: 'NewExternal' is deprecated [-Wdeprecated-declarations] 
    return v8::String::NewExternal(v8::Isolate::GetCurrent(), resource); 
        ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:2372:38: note: 'NewExternal' has been explicitly marked deprecated here 
         Local<String> NewExternal(
            ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:623:19: error: no type named 'ExternalAsciiStringResource' in 'v8::String'; did you mean 'ExternalStringResource'? 
     v8::String::ExternalAsciiStringResource *resource) { 
     ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ 
        ExternalStringResource 
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:2241:19: note: 'ExternalStringResource' declared here 
    class V8_EXPORT ExternalStringResource 
       ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:622:36: error: redefinition of 'NanNew' 
    NAN_INLINE v8::Local<v8::String> NanNew(
           ^
../../nan/nan.h:617:36: note: previous definition is here 
    NAN_INLINE v8::Local<v8::String> NanNew(
           ^
../../nan/nan.h:624:24: warning: 'NewExternal' is deprecated [-Wdeprecated-declarations] 
    return v8::String::NewExternal(v8::Isolate::GetCurrent(), resource); 
        ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:2372:38: note: 'NewExternal' has been explicitly marked deprecated here 
         Local<String> NewExternal(
            ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:637:27: error: redefinition of '_NanEscapeScopeHelper' 
    NAN_INLINE v8::Local<T> _NanEscapeScopeHelper(v8::Local<T> val) { 
         ^
../../nan/nan.h:632:27: note: previous definition is here 
    NAN_INLINE v8::Local<T> _NanEscapeScopeHelper(v8::Handle<T> val) { 
         ^
../../nan/nan.h:653:12: error: no matching function for call to '_NanEscapeScopeHelper' 
    return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent()))); 
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
../../nan/nan.h:641:43: note: expanded from macro 'NanEscapeScope' 
# define NanEscapeScope(val) scope.Escape(_NanEscapeScopeHelper(val)) 
              ^~~~~~~~~~~~~~~~~~~~~ 
../../nan/nan.h:637:27: note: candidate template ignored: substitution failure [with T = v8::Primitive] 
    NAN_INLINE v8::Local<T> _NanEscapeScopeHelper(v8::Local<T> val) { 
         ^
../../nan/nan.h:658:12: error: no matching function for call to '_NanEscapeScopeHelper' 
    return NanEscapeScope(NanNew(v8::Null(v8::Isolate::GetCurrent()))); 
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
../../nan/nan.h:641:43: note: expanded from macro 'NanEscapeScope' 
# define NanEscapeScope(val) scope.Escape(_NanEscapeScopeHelper(val)) 
              ^~~~~~~~~~~~~~~~~~~~~ 
../../nan/nan.h:637:27: note: candidate template ignored: substitution failure [with T = v8::Primitive] 
    NAN_INLINE v8::Local<T> _NanEscapeScopeHelper(v8::Local<T> val) { 
         ^
../../nan/nan.h:663:12: error: no matching function for call to '_NanEscapeScopeHelper' 
    return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent()))); 
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
../../nan/nan.h:641:43: note: expanded from macro 'NanEscapeScope' 
# define NanEscapeScope(val) scope.Escape(_NanEscapeScopeHelper(val)) 
              ^~~~~~~~~~~~~~~~~~~~~ 
../../nan/nan.h:637:27: note: candidate template ignored: substitution failure [with T = v8::Boolean] 
    NAN_INLINE v8::Local<T> _NanEscapeScopeHelper(v8::Local<T> val) { 
         ^
../../nan/nan.h:668:12: error: no matching function for call to '_NanEscapeScopeHelper' 
    return NanEscapeScope(NanNew(v8::False(v8::Isolate::GetCurrent()))); 
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
../../nan/nan.h:641:43: note: expanded from macro 'NanEscapeScope' 
# define NanEscapeScope(val) scope.Escape(_NanEscapeScopeHelper(val)) 
              ^~~~~~~~~~~~~~~~~~~~~ 
../../nan/nan.h:637:27: note: candidate template ignored: substitution failure [with T = v8::Boolean] 
    NAN_INLINE v8::Local<T> _NanEscapeScopeHelper(v8::Local<T> val) { 
         ^
../../nan/nan.h:701:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate' 
     v8::Isolate::GCEpilogueCallback callback 
     ~~~~~~~~~~~~~^ 
../../nan/nan.h:707:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate' 
     v8::Isolate::GCEpilogueCallback callback) { 
     ~~~~~~~~~~~~~^ 
../../nan/nan.h:712:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate' 
     v8::Isolate::GCPrologueCallback callback 
     ~~~~~~~~~~~~~^ 
../../nan/nan.h:718:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate' 
     v8::Isolate::GCPrologueCallback callback) { 
     ~~~~~~~~~~~~~^ 
../../nan/nan.h:889:13: error: no member named 'smalloc' in namespace 'node' 
    , node::smalloc::FreeCallback callback 
     ~~~~~~^ 
../../nan/nan.h:900:12: error: no matching function for call to 'New' 
    return node::Buffer::New(v8::Isolate::GetCurrent(), data, size); 
      ^~~~~~~~~~~~~~~~~ 
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/node_buffer.h:46:40: note: candidate function not viable: 2nd argument ('const char *') would lose const qualifier 
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, 
            ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/node_buffer.h:34:40: note: candidate function not viable: no known conversion from 'const char *' to 'v8::Local<v8::String>' for 2nd argument 
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, 
            ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/node_buffer.h:31:40: note: candidate function not viable: requires 2 arguments, but 3 were provided 
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length); 
            ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/node_buffer.h:39:40: note: candidate function not viable: requires 5 arguments, but 3 were provided 
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, 
            ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:904:12: error: no viable conversion from returned value of type 'v8::MaybeLocal<v8::Object>' to function return type 'v8::Local<v8::Object>' 
    return node::Buffer::New(v8::Isolate::GetCurrent(), size); 
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:218:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'v8::MaybeLocal<v8::Object>' to 
     'const v8::Local<v8::Object> &' for 1st argument 
class Local { 
    ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:218:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'v8::MaybeLocal<v8::Object>' to 
     'v8::Local<v8::Object> &&' for 1st argument 
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:222:13: note: candidate template ignored: could not match 'Local' against 'MaybeLocal' 
    V8_INLINE Local(Local<S> that) 
      ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:911:26: error: no member named 'Use' in namespace 'node::Buffer' 
    return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size); 
      ~~~~~~~~~~~~~~^ 
../../nan/nan.h:938:32: warning: 'Compile' is deprecated [-Wdeprecated-declarations] 
    return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source); 
          ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:1354:21: note: 'Compile' has been explicitly marked deprecated here 
     Local<Script> Compile(Isolate* isolate, Source* source, 
        ^
In file included from ../src/java.cpp:2: 
In file included from ../src/java.h:9: 
../../nan/nan.h:945:32: warning: 'Compile' is deprecated [-Wdeprecated-declarations] 
    return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &source); 
          ^
/Users/bogdangheorghe/.node-gyp/6.10.3/include/node/v8.h:1354:21: note: 'Compile' has been explicitly marked deprecated here 
     Local<Script> Compile(Isolate* isolate, Source* source, 
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=] 
15 warnings and 20 errors generated. 
make: *** [Release/obj.target/nodejavabridge_bindings/src/java.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/npm/node_modules/node-gyp/lib/build.js:276:23) 
gyp ERR! stack  at emitTwo (events.js:106:13) 
gyp ERR! stack  at ChildProcess.emit (events.js:191:7) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12) 
gyp ERR! System Darwin 16.5.0 
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 
gyp ERR! cwd /Users/bogdangheorghe/Workspace/Servers/RCPHelper_Server/RCPHelper_Server/node_modules/java 
gyp ERR! node -v v6.10.3 
gyp ERR! node-gyp -v v3.4.0 
gyp ERR! not ok 
/Users/bogdangheorghe/Workspace/Servers/RCPHelper_Server/RCPHelper_Server 
└── (empty) 

npm WARN enoent ENOENT: no such file or directory, open '/Users/bogdangheorghe/Workspace/Servers/RCPHelper_Server/RCPHelper_Server/package.json' 
npm WARN RCPHelper_Server No description 
npm WARN RCPHelper_Server No repository field. 
npm WARN RCPHelper_Server No README data 
npm WARN RCPHelper_Server No license field. 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/java): 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild` 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1 
npm ERR! code 1 
Bogdans-MBP:mongojs bogdangheorghe$ 

我再試着刪除mongojs,手動從這裏下載:https://github.com/mafintosh/mongojs,然後做一個NPM使用的package.json文件安裝的package.json那帶着包,我得到了這一點:

Bogdans-MBP:mongojs bogdangheorghe$ ls 
CHANGELOG.md CONTRIBUTING.md LICENSE  README.md index.js lib  package.json release.js test 
Bogdans-MBP:mongojs bogdangheorghe$ sudo npm install package.json 
npm ERR! not a package /Users/bogdangheorghe/Workspace/Servers/RCPHelper_Server/RCPHelper_Server/node_modules/mongojs/package.json 
npm ERR! addLocal Could not install /Users/bogdangheorghe/Workspace/Servers/RCPHelper_Server/RCPHelper_Server/node_modules/mongojs/package.json 
npm ERR! Darwin 16.5.0 
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "package.json" 
npm ERR! node v6.10.3 
npm ERR! npm v3.10.10 
npm ERR! path /tmp/npm-76762-ff2259cf/unpack-aba50b3b/package.json 
npm ERR! code ENOENT 
npm ERR! errno -2 
npm ERR! syscall open 

npm ERR! enoent ENOENT: no such file or directory, open '/tmp/npm-76762-ff2259cf/unpack-aba50b3b/package.json' 
npm ERR! enoent ENOENT: no such file or directory, open '/tmp/npm-76762-ff2259cf/unpack-aba50b3b/package.json' 
npm ERR! enoent This is most likely not a problem with npm itself 
npm ERR! enoent and is related to npm not being able to find a file. 
npm ERR! enoent 

npm ERR! Please include the following file with any support request: 
npm ERR!  /Users/bogdangheorghe/Workspace/Servers/RCPHelper_Server/RCPHelper_Server/node_modules/mongojs/npm-debug.log 
Bogdans-MBP:mongojs bogdangheorghe$ 

同樣的結果在Windows 10:

enter image description here

我也嘗試重新安裝節點沒有任何運氣。 我一直在努力解決這個問題近一天,迄今爲止沒有成功。 我在這裏做錯了什麼?

回答

1

更新節點

  • NPM安裝-g NPM @最新

要刪除模塊,始終做到用NPM它:

  • NPM卸載mongojs

您可以再次安裝它:

對於一個新項目: - CD project_folder - NPM初始化-y - NPM安裝--save mongojs

如果現有項目: - CD project_folder - NPM安裝--save mongojs

你可以直接使用它:

var mongo = require('mongojs');

+0

感謝您的信息。 npm install --save mongojs完成了這個任務。有點。安裝時我確實得到了這一切:https://pastebin.com/cqTpgNQh – daydr3am3r