After updating to Windows 11 from windows 10 I was getting the above mentioned error message. Running the command in powershell/ command prompt/ terminal in admin permission did not work. But when ran from git bash in VS code it worked.
https://www.reddit.com/r/node/comments/qz6u86/help_cant_enable_corepack/?rdt=39252