'Sanity check failed when installing Haskell Stack on Windows

I've been trying to install Haskell Stack on Windows, but when I try this command:

>stack setup --resolver lts-18.26

the following error occurs:

The GHC located at C:\Users\Atanasia\AppData\Local\Programs\stack\x86_64-windows\ghc-8.10.7\bin\ghc-8.10.7.exe 
failed to compile a sanity check. Please see:

    http://docs.haskellstack.org/en/stable/install_and_upgrade/

for more information. Exception was:
Received ExitFailure 1 when running
Raw command: 
"C:\\Users\\Atanasia\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.10.7\\bin\\ghc-8.10.7.exe" 
  "C:\\Users\\Atanasia\\AppData\\Local\\Temp\\stack-sanity-check-8ee50ed0f920a51a\\Main.hs" 
  -no-user-package-db

Run from: C:\Users\Atanasia\AppData\Local\Temp\stack-sanity-check-8ee50ed0f920a51a\

Also, for this command:

>stack ghci -- --version

I receive:

Found an invalid compiler at "C:\\Users\\Atanasia\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.10.7\\bin\\ghc-8.10.7.exe": 
Received ExitFailure 1 when running
Raw command: 
"C:\\Users\\Atanasia\\AppData\\Local\\Programs\\stack\\x86_64-windows\\ghc-8.10.7\\bin\\ghc-8.10.7.exe"
   --info


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source