Windows Powershell Disabled by default
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 279
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 2
Description
Info
Windows: 10 v19045.2251
Node: v18.12.1
Yarn: v3.3.0
Issue
Windows does not allow powershell scripts to be run by default.
In full:
yarn : File C:\Program Files\nodejs\yarn.ps1 cannot be loaded because running scripts is disabled on this system. For more inf
ormation, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ yarn -v
+ ~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Replication
As administrator run the following console commands:
corepack enable
corepack prepare yarn@stable --activate
yarn -v
Sollution
If you have access to overwrite the global powershell policies, this is easy to solve. In many Enterprice settings this isn't going to be an option, however, even when you have the local administrative rights to run the "corepack" commands on your local machine.
What you can do, is to rename the "yarn.ps1" file to something like "yarnABC.ps1". Then the system seems to default to the "yarn.CMD" file instead, which works just fine.
Powershell files in corepack
I'm not sure why "corepack enable" creates .ps1 files for the corepack utilities, when there aren't any for npx or npm, but this will cause an issue in a lot of Enterprise settings, and if the .ps1 files aren't necessary, then maybe they could be removed in a future update?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the corepack enable entry point and inspect the generated yarn.ps1 and yarn.CMD files under the reported Windows execution-policy conditions. Determine whether the PowerShell shim is necessary and verify that package-manager commands work without requiring enterprise policy changes; add or update validation for the Windows behavior if the repository provides it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, powershell
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100