【问题标题】:Can't Update NPM to its Latest Version无法将 NPM 更新到最新版本
【发布时间】:2020-07-24 04:17:43
【问题描述】:

按照某个教程,我将我的 npm 从 6.14.1 降级到 5.5.1 版。但是每次我使用 npm 安装一个包时,它就不再工作并且已经出现了兼容性问题。它说:

npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! cb.apply is not a function

我已经安装了最新版本的 node.js,即 v14.6.0,但我仍然遇到了同样的问题。我尝试使用 npm i -g npm@latest 更新我的 npm,但仍然无法正常工作。我也试过 npm install -g npm-windows-upgrade 但我只得到这些错误:

npm WARN npm npm does not support Node.js v14.6.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
WARNING: You are likely using a version of node-tar or npm that is incompatible with this version of Node.js.
Please use either the version of npm that is bundled with Node.js, or a version of npm (> 5.5.1 or < 5.4.0) or node-tar (> 4.0.1) that is compatible with Node.js 9 and above.
npm[20932]: c:\ws\src\node_zlib.cc:573: Assertion `args.Length() == 7 && "init(windowBits, level, memLevel, strategy, writeResult, writeCallback," " dictionary)"' failed.
 1: 00007FF67312FF3F napi_wrap+110015
 2: 00007FF6730D5F36 v8::internal::OrderedHashTable<v8::internal::OrderedHashMap,2>::NumberOfElementsOffset+33350
 3: 00007FF6730D62B1 v8::internal::OrderedHashTable<v8::internal::OrderedHashMap,2>::NumberOfElementsOffset+34241
 4: 00007FF67300E52A v8::internal::Isolate::isolate_root_bias+77290
 5: 00007FF67393690F v8::internal::Builtins::builtin_handle+321503
 6: 00007FF673935E9E v8::internal::Builtins::builtin_handle+318830
 7: 00007FF673936197 v8::internal::Builtins::builtin_handle+319591
 8: 00007FF673935FE3 v8::internal::Builtins::builtin_handle+319155
 9: 00007FF673A1260D v8::internal::SetupIsolateDelegate::SetupHeap+464173
10: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
11: 00007FF6739A6CFA v8::internal::SetupIsolateDelegate::SetupHeap+23578
12: 00007FF673A909B3 v8::internal::SetupIsolateDelegate::SetupHeap+981203
13: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
14: 00007FF6739A4B49 v8::internal::SetupIsolateDelegate::SetupHeap+14953
15: 00007FF6739A6CD1 v8::internal::SetupIsolateDelegate::SetupHeap+23537
16: 00007FF673A909B3 v8::internal::SetupIsolateDelegate::SetupHeap+981203
17: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
18: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
19: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
20: 00007FF6739A4B49 v8::internal::SetupIsolateDelegate::SetupHeap+14953
21: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
22: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
23: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
24: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
25: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
26: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
27: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
28: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
29: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
30: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
31: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
32: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
33: 00007FF6739A4B49 v8::internal::SetupIsolateDelegate::SetupHeap+14953
34: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
35: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
36: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
37: 00007FF6739AAF12 v8::internal::SetupIsolateDelegate::SetupHeap+40498
38: 00007FF6739A8BCE v8::internal::SetupIsolateDelegate::SetupHeap+31470
39: 00007FF6739A87BC v8::internal::SetupIsolateDelegate::SetupHeap+30428
40: 00007FF67388CB19 v8::internal::Execution::CallWasm+1657
41: 00007FF67388C37F v8::internal::Execution::Call+191
42: 00007FF673963B77 v8::Function::Call+615
43: 00007FF67315365D node::CallbackScope::~CallbackScope+861
44: 00007FF67315399B node::CallbackScope::~CallbackScope+1691
45: 00007FF673153E81 node::MakeCallback+209
46: 00007FF67311EB6E napi_wrap+39406
47: 00007FF6731789C8 uv_check_init+120

谁能帮帮我。谢谢!

【问题讨论】:

    标签: node.js windows npm


    【解决方案1】:

    检查this。 npm windows 升级工具使整个过程自动化。 npm-windows-upgrade --npm-version latest 并且该工具将向您显示 npm 的最新和可用版本的列表。选择您要安装的那个,剩下的就交给它了。

    【讨论】:

    • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
    • 感谢您的提醒,对此仍然很陌生。
    • 感谢@Emily 的帮助,尝试了这种方法,但遗憾的是它对我不起作用。
    【解决方案2】:

    我发现我正在另一个窗口中运行一个反应应用程序。我试图用这个来更新节点 js 正在运行。当我停止它运行、卸载并重新安装时,这个错误就停止了。

    【讨论】:

      【解决方案3】:

      我从一群遇到与我相同问题的人那里找到了答案,它对我有用。我只是从 github 安装了 Node Version Manager 并以管理员身份运行 cmd 然后执行 nvm install latestnvm use。现在,一切正常。

      这里是 NVM 安装完整指南的链接: NVM for Windows

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-12-04
        • 2023-03-19
        • 2017-10-03
        • 2017-02-02
        • 1970-01-01
        • 2014-12-04
        • 1970-01-01
        相关资源
        最近更新 更多