Open jacobaagaardbennike opened 1 year ago
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.
Another "workaround" is to always prefix the yarn command with "corepack", e.g. corepack yarn start
. Not ideal of course, but it might unblock you as it should work in all cases corepack
itself is available.
We could introduce a new env variable to disable the creation of .ps1
, or maybe a CLI flag (e.g. corepack enable --no-powershell
). I'm not familiar enough with Windows to know if not having .ps1
by default would make sense, but making it opt-out would be a good first step I think. Would you like to contribute a PR?
This is a definitely a problem for Windows users after upgrading to yarn 4.
Another option is to add aliases to your PowerShell profile as documented here: https://github.com/nodejs/corepack/tree/b9eea589b4535d32b8e9ca1e884c3a44bf7d99ea#corepack-enable--name
It's a require additional steps by developers, while previously it was just clone and go
solution with yarnPath
This is off-topic but you can still use yarnPath
if you want https://yarnpkg.com/cli/set/version#options.
I think the real solution for this issue will be just sign this scripts with the same key as used for Node.js itself.
Isn't this script basically dynamically created? I don't think that it is a static file that can be presigned. Just don't create a ps1 file.
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:
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?