Do you want to request a feature or report a bug?
bug (regression?)
What is the current behavior?
yarn add global fails with EPERM: operation not permitted
If the current behavior is a bug, please provide the steps to reproduce.
yarn init and then yarn global add codeceptjsWhat is the expected behavior?
same as npm -g install codeceptjs i.e. install the package globally without errors
Please mention your node.js, yarn and operating system version.
nodejs v7.8
yarn v0.22.0
windows 10 pro x64
Stacktrace:
yarn init v0.22.0
question name (shaadi-try):
question version (1.0.0):
question description:
question entry point (index.js):
question repository url:
question author:
question license (MIT):
success Saved package.json
Done in 4.13s.
C:\my-home\AutomationProjects\CodeceptProjects\shaadi-try>yarn global add codeceptjs
yarn global v0.22.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "[email protected]" with binaries:
- codeceptjs
error An unexpected error occurred: "EPERM: operation not permitted, open 'C:\\Program Files\\nodejs\\codeceptjs.cmd'".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\Dheeraj\\AppData\\Local\\Yarn\\config\\global\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
yarn error log:
https://gist.github.com/dheerajbhaskar/07cdc55e1d80282c4782f948638fa7c4
Wasn't this fixed sometime back?
C:\my-home\AutomationProjects\CodeceptProjects\shaadi-try>yarn global bin
C:\Program Files\nodejs
You have to run this command as amministrator on windows systems
There's a known bug at the moment where we're trying to install global packages into the Node.js directory rather than Yarn's AppData directory.
Npm I -g doesn't require admin privileges, why should yarn.
If this is a temporary fix for a known bug, then it's fine 馃檪
Npm I -g doesn't require admin privileges, why should yarn.
That's because yarn is trying to install the link to the package inside /Program Files/ and in windows you need admin privileges to write in this folder:
"EPERM: operation not permitted, open 'C:\Program Files\nodejs\codeceptjs.cmd'"
Well, I understand the technical reason why it's asking now 馃檪.
What I meant was why could it not be done without putting a file in program
files. I believe npm puts it in %appdata% or thereabouts which doesn't need
admin privileges.
Yes, that's the bug. It's not supposed to put the packages in Program Files. It's supposed to put them in LocalAppData.
I was getting the same issue on Windows 10
I'm hitting this issue today when I try to migrate from npm.
Seems there are more aging issues talking about the same.
https://github.com/yarnpkg/yarn/issues/992
https://github.com/yarnpkg/yarn/issues/1407
https://github.com/yarnpkg/yarn/issues/2192
If anyone wants to investigate this, pull requests are always appreciated! It just sounds like whatever code determines the directory for global packages is incorrectly returning the Program Files directory.
Luke123443 is correct, That's because yarn is trying to install the link to the package inside /Program Files/ and in windows you need admin privileges to write in this folder:
"EPERM: operation not permitted, open 'C:\Program Files\nodejs
I tried the last couple of hours to migrate from npm, but I give up: every successful workaround leads to a new permission error on another file.
I'm not complaining since my current programming level doesn't allow me to contribute and help solving the issue. I could move to Ubuntu, so staying on Windows is my personal choice and there are consequences I must live with.
However, I still wonder: isn't basically every Windows likely to meet this issue? Can it reasonably be said that yarn supports Windows since the bug is around since last October?
If it's bleeding edge, half-skilled amateur dev like me could maybe be warned to stay away for now.
Submitted a diff to fix this: #3233
Can it reasonably be said that yarn supports Windows since the bug is around since last October?
The bug only affects global packages, which are very rarely used compared to regular (local) packages. The only use case for global packages is for things that are not specific to one project (for example, scaffolding tools like create-react-app and yeoman). Almost everything else is specific to a project and thus should go into that project's package.json file as a dependency.
By the way, I found a workaround that worked on my pc: use chocolatey to install yarn (as proposed on the yarn website).