【问题标题】:cordova installation error -Command failed: powershell (Get-CimInstance -ClassName Win32_OperatingSystem).caption The term 'Get-CimInstance' is not recordova 安装错误 - 命令失败:powershell (Get-CimInstance -ClassName Win32_OperatingSystem).caption 术语“Get-CimInstance”不是
【发布时间】:2021-09-07 03:01:09
【问题描述】:

我尝试使用“npm install -g cordova”安装cordova 当我运行命令“cordova -v”或“cordova -V”或“cordova --version”时 我收到此错误。 请帮忙解决问题

C:\Users\Admin>cordova -v
C:\Users\Admin\AppData\Roaming\npm\node_modules\cordova\node_modules\windows-release\node_modules\execa\index.js:347
                throw err;
                ^

Error: Command failed: powershell (Get-CimInstance -ClassName Win32_OperatingSystem).caption
The term 'Get-CimInstance' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
 a path was included, verify that the path is correct and try again.
At line:1 char:17
+ (Get-CimInstance <<<<  -ClassName Win32_OperatingSystem).caption
    + CategoryInfo          : ObjectNotFound: (Get-CimInstance:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException



    at makeError (C:\Users\Admin\AppData\Roaming\npm\node_modules\←[4mcordova←[24m\node_modules\←[4mwindows-release←[24m\node_modules\←[4mexeca←[24m\ind
ex.js:174:9)
    at Function.module.exports.sync (C:\Users\Admin\AppData\Roaming\npm\node_modules\←[4mcordova←[24m\node_modules\←[4mwindows-release←[24m\node_modules
\←[4mexeca←[24m\index.js:338:15)
    at windowsRelease (C:\Users\Admin\AppData\Roaming\npm\node_modules\←[4mcordova←[24m\node_modules\←[4mwindows-release←[24m\index.js:39:19)
    at osName (C:\Users\Admin\AppData\Roaming\npm\node_modules\←[4mcordova←[24m\node_modules\←[4mos-name←[24m\index.js:39:18)
    at new Insight (C:\Users\Admin\AppData\Roaming\npm\node_modules\←[4mcordova←[24m\node_modules\←[4minsight←[24m\lib\index.js:37:13)
    at new RelentlessInsight (C:\Users\Admin\AppData\Roaming\npm\node_modules\←[4mcordova←[24m\src\telemetry.js:31:1)
    at Object.<anonymous> (C:\Users\Admin\AppData\Roaming\npm\node_modules\←[4mcordova←[24m\src\telemetry.js:39:15)
←[90m    at Module._compile (internal/modules/cjs/loader.js:1118:30)←[39m
←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:982:32)←[39m {
  code: ←[33m1←[39m,
  stdout: ←[32m''←[39m,
  stderr: ←[32m"The term 'Get-CimInstance' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if\r\n"←[39m +
    ←[32m' a path was included, verify that the path is correct and try again.\r\n'←[39m +
    ←[32m'At line:1 char:17\r\n'←[39m +
    ←[32m'+ (Get-CimInstance <<<<  -ClassName Win32_OperatingSystem).caption\r\n'←[39m +
    ←[32m'    + CategoryInfo          : ObjectNotFound: (Get-CimInstance:String) [], CommandNotFoundException\r\n'←[39m +
    ←[32m'    + FullyQualifiedErrorId : CommandNotFoundException\r\n'←[39m +
    ←[32m' \r\n'←[39m,
  failed: ←[33mtrue←[39m,
  signal: ←[1mnull←[22m,
  cmd: ←[32m'powershell (Get-CimInstance -ClassName Win32_OperatingSystem).caption'←[39m,
  timedOut: ←[33mfalse←[39m
}

C:\Users\Admin>

【问题讨论】:

  • 所以错误告诉您Get-Ciminstance 未被识别为命令,您使用的是什么powershell 版本和操作系统? Get-Ciminstance 至少需要 powershell v3
  • window 7 专业版 32 位中的 v2
  • 据我所知,CIM-* cmdlet 不存在于 ps2 中。我怀疑您尝试使用的软件与您使用的旧版 Windows 不兼容。

标签: node.js powershell cordova npm node-modules


【解决方案1】:

Get-CimInstance 是在 Powershell v3 中引入的。它以前不可用。

Powershell v2 中的大致等价物是Get-WmiObject,但请注意,该命令已被Get-Cim* 命令取代和弃用。从 Powershell v6 开始,Get-WmiObject 不再存在。

Powershell v2 和 Windows 7 均已停产(截至 2020 年 1 月),应被视为不安全且不适合现代使用。也就是说,Windows 7 确实通过Windows Management Framework 5.1 支持 Powershell v5,尽管 Microsoft 不再有义务为 Windows 7 托管该文件,因此它可能不再可用。

【讨论】:

  • 是的,我将我的 powershell 更新到了 v3。现在一切正常
猜你喜欢
  • 2021-01-06
  • 2020-01-19
  • 2021-07-02
  • 2022-11-04
  • 1970-01-01
  • 1970-01-01
  • 2021-08-29
  • 2022-01-13
  • 2019-08-31
相关资源
最近更新 更多