0

I run my project with npm in WebStorm terminal and it runs fine. But with yarn it gives this error (Yarn runs with CMD correctly):

enter image description here

I searched that here and saw this answer:

How to create run configuration with Yarn instead of npm in WebStorm 2016.2.3

But I have yarn package on my WebStorm. See the below image:

enter image description here

So I don't know what is the problem. Any idea?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Arman Ebrahimi
  • 2,035
  • 2
  • 7
  • 20
  • @LazyOne Thanks. But why does it run with `npm` fine, while it needs to `Set-ExecutionPolicy RemoteSigned` for `yarn`? – Arman Ebrahimi May 17 '22 at 10:45
  • `npm` is a `.cmd` (Windows Batch file). `yarn` seems to have both `.cmd` and `.ps1` files (PowerShell module). `.ps1` is used in PowerShell session while in CMD session (standard `cmd.exe` shell) the `.cmd` file will be used. Run `powershell.exe` session outside of the IDE (e.g. `Win+R` then `powershell`) and you _should_ see the same result. Or use `cmd.exe` inside WebStorm as your shell instead of `powershell`. – LazyOne May 17 '22 at 11:00
  • 1
    PowerShell's Execution Policy affects PowerShell files (`.ps1` etc) only. It does not affect `.exe`, `.bat` or `.cmd`. – LazyOne May 17 '22 at 11:02
  • 1
    Basically, in your current WebStorm's terminal (PowerShell) -- run `Get-Command npm` then run `Get-Command yarn` and see what files will be executed if you run `npm` and `yarn` commands. I bet for _yarn_ it will be `yarn.ps1` while _npm_ will have `npm.cmd`. Especially see the info from the `CommandType` column: "Application" for _npm_ and "ExternalScript" for _yarn_ . The issue you are having is not WebStorm, it's PowerShell (security config). – LazyOne May 17 '22 at 11:07
  • @LazyOne Thanks for the complete explanations :) – Arman Ebrahimi May 17 '22 at 15:04

0 Answers0