我刚刚开始学习离子应用程序,一切进展顺利,直到我必须添加平台为止。我运行了以下命令:
ionic cordova platform add android
这就是我得到的:
> cordova.cmd platform add android
C:\Users\Stephynoe\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
operable program or batch file.as an internal or external command,
at makeError (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\node_modules\windows-release\node_modules\execa\index.js:174:9)
at Function.module.exports.sync (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\node_modules\windows-release\node_modules\execa\index.js:338:15)
at windowsRelease (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\node_modules\windows-release\index.js:39:19)
at osName (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\node_modules\os-name\index.js:39:18)
at new Insight (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\node_modules\insight\lib\index.js:37:13)
at new RelentlessInsight (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\src\telemetry.js:31:1)
at Object.<anonymous> (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\src\telemetry.js:39:15)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32) {
code: 1,
stdout: '',
stderr: "'powershell' is not recognized as an internal or external command,\r\n" +
'operable program or batch file.\r\n',
failed: true,
signal: null,
cmd: 'powershell (Get-CimInstance -ClassName Win32_OperatingSystem).caption',
timedOut: false
}
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd platform add android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
在线阅读了很多解决方案后,我已经卸载并重新安装了cordova,即使尝试检查已安装的cordova版本,我仍然会收到类似的错误消息。如果有人能为我提供可行的解决方案,我将感到非常高兴。谢谢。 成功设置powershell7内核后,我遇到了这个错误
throw err;
^
Error: Command failed: powershell (Get-CimInstance -ClassName Win32_OperatingSystem).caption
The argument '(Get-CimInstance -ClassName Win32_OperatingSystem).caption' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Usage: pwsh[.exe] [-Login] [[-File] <filePath> [args]]
[-Command { - | <script-block> [-args <arg-array>]
| <string> [<CommandParameters>] } ]
[-ConfigurationName <string>] [-CustomPipeName <string>]
[-EncodedCommand <Base64EncodedCommand>]
[-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}]
[-Interactive] [-MTA] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile]
[-OutputFormat {Text | XML}] [-SettingsFile <filePath>] [-STA] [-Version]
[-WindowStyle <style>] [-WorkingDirectory <directoryPath>]
pwsh[.exe] -h | -Help | -? | /?
PowerShell Online Help https://aka.ms/powershell-docs
All parameters are case-insensitive.
at makeError (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\node_modules\windows-release\node_modules\execa\index.js:174:9)
at Function.module.exports.sync (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\node_modules\windows-release\node_modules\execa\index.js:338:15)
at windowsRelease (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\node_modules\windows-release\index.js:39:19)
at osName (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\node_modules\os-name\index.js:39:18)
at new Insight (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\node_modules\insight\lib\index.js:37:13)
at new RelentlessInsight (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\src\telemetry.js:31:1)
at Object.<anonymous> (C:\Users\Stephynoe\AppData\Roaming\npm\node_modules\cordova\src\telemetry.js:39:15)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32) {
code: 64,
stdout: '\r\n' +
'Usage: pwsh[.exe] [-Login] [[-File] <filePath> [args]]\r\n' +
' [-Command { - | <script-block> [-args <arg-array>]\r\n' +
' | <string> [<CommandParameters>] } ]\r\n' +
' [-ConfigurationName <string>] [-CustomPipeName <string>]\r\n' +
' [-EncodedCommand <Base64EncodedCommand>]\r\n' +
' [-ExecutionPolicy <ExecutionPolicy>] [-InputFormat {Text | XML}]\r\n' +
' [-Interactive] [-MTA] [-NoExit] [-NoLogo] [-NonInteractive] [-NoProfile]\r\n' +
' [-OutputFormat {Text | XML}] [-SettingsFile <filePath>] [-STA] [-Version]\r\n' +
' [-WindowStyle <style>] [-WorkingDirectory <directoryPath>]\r\n' +
'\r\n' +
' pwsh[.exe] -h | -Help | -? | /?\r\n' +
'\r\n' +
'PowerShell Online Help https://aka.ms/powershell-docs\r\n' +
'\r\n' +
'All parameters are case-insensitive.\r\n',
stderr: "The argument '(Get-CimInstance -ClassName Win32_OperatingSystem).caption' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.\r\n",
failed: true,
signal: null,
cmd: 'powershell (Get-CimInstance -ClassName Win32_OperatingSystem).caption',
timedOut: false
}```