In later versions of Windows 10 WMIC seems to be deprecated. For example, if i try ionic info I get an error message:
Error: Command failed: wmic os get Caption
ERROR:
Description = Unspecified error
at makeError (C:\Users\andersp\AppData\Roaming\npm\node_modules\@ionic\cli\node_modules\execa\index.js:174:9)
at Function.module.exports.sync
(C:\Users\andersp\AppData\Roaming\npm\node_modules\@ionic\cli\node_modules\execa\index.js:338:15)
at windowsRelease
(C:\Users\andersp\AppData\Roaming\npm\node_modules\@ionic\cli\node_modules\windows-release\index.js:34:24)
at osName (C:\Users\andersp\AppData\Roaming\npm\node_modules\@ionic\cli\node_modules\os-name\index.js:39:18)
at Environment.getInfo (C:\Users\andersp\AppData\Roaming\npm\node_modules\@ionic\cli\lib\index.js:45:20)
at async InfoCommand.run (C:\Users\andersp\AppData\Roaming\npm\node_modules\@ionic\cli\commands\info.js:29:24)
at async Promise.all (index 0)
at async InfoCommand.execute (C:\Users\andersp\AppData\Roaming\npm\node_modules\@ionic\cli\lib\command.js:79:9)
at async Executor.run (C:\Users\andersp\AppData\Roaming\npm\node_modules\@ionic\cli\lib\executor.js:53:9)
at async Executor.execute
(C:\Users\andersp\AppData\Roaming\npm\node_modules\@ionic\cli\node_modules\@ionic\cli-framework\lib\executor.js:69:13)
This means I can no longer compile or do anything with my project.
Iâm using Ionic 4 and Cordova 9. Iâm pretty stumped as what to do now.
Itâs a tool used on Windows Server machines to look up/specify different OS specifications (if I understand correctly). WMIC stands for Windows Management Instrumentation Command-line utility. Itâs apparently deprecated and MS encourages the use of PowerShell commandlets instead. But it works on an older Win10 installation I have. But in this version it just returns an error.
The specific command it tries to run is: wmic os get caption, to determine which windows server version itâs running on.
The file that throws the error is this one:
C:\Users\andersp\AppData\Roaming\npm\node_modules@ionic\cli\node_modules\windows-release\index.js
And the code that crashes is this bit, from line 33:
If I comment out that bit everything works. Itâs the same problem with Cordova, in file:
C:\Users\andersp\AppData\Roaming\npm\node_modules\cordova\node_modules\windows-release\index.js
Iâm pretty new to Node, so is âwindows-releaseâ a common node module that can be updated?
Anyway, if I comment out those lines it all works again.
Ah, nice one! Didnât see that, but looks about the same as what I came up with. Iâm not sure how stable that solution is though. With regards to user privileges and such.
Do you recon someone will implement the powershell solution to âwindows-releaseâ in the future? Would be neat, that way I donât need to change those rows when download the project to another computer.
Judging from the level of activity on that repo, I canât honestly say I would feel particularly sanguine about that prospect. I would love to make a PR myself, but the last time I used any version of Windows was 1987, so saying this is not exactly an area of competence for me would be a drastic understatement.
Hahaha, gotcha. Hmmmm, Iâm pretty new to the whole git stuff. But I managed to clone it, and make the change, so maybe Iâll try a pull request and see what happens.
I think https://github.com/susam/gitpr is a good cribsheet for the general process, although, it may be a bit like trying to drink from a fire hydrant the first time you go through it.
I made a stupid mistake. By just replacing wmic for powershell it might break on older OS:es. So made a new commit to the pull request where I added an error check. So if the wmic call works it works like the old version, but if we get an error it tries the new Powershell command. So code now looks like this: