Do you want to request a feature or report a bug?
BUG
What is the current behavior?
I'm receiving the following error when running yarn:
$ yarn --version
module.js:471
throw err;
^
Error: Cannot find module 'C:\c\Program Files (x86)\Yarn\bin\yarn.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
Looks like the path is invalid:
C:\c\Program Files (x86)\Yarn\bin\yarn.js
should be:
C:\Program Files (x86)\Yarn\bin\yarn.js
An extra "c\" directory level is being added.
If the current behavior is a bug, please provide the steps to reproduce.
I was previously running version 0.18.1. Downloaded the latest Windows MSI - yarn-0.19.1.msi and ran the installation. No errors seen. I've rolled back to 0.18.1 and it works fine.
I tried removing completely and installing from fresh but get the same error.
Oddly, I went through the same process on another machine yesterday and it worked fine. I can't recall but I think I was previously on 0.19.0 on this machine, which is only difference I can think of.
What is the expected behavior?
Expected to run as it did previously - and simply print out the version of Yarn.
Please mention your node.js, yarn and operating system version.
Running Windows 7 Enterprise ed, node version: 6.9.1
Can't reproduce on windows 10:
node 7.3.0
Same problem:
_Error: Cannot find module 'D:\c\Program Files (x86)\Yarn\bin\yarn.js'_
Note I'm running yarn command from folder on D: drive
yarn-0.20.3.msi [same problem]
yarn-0.19.1.msi [same problem]
yarn-0.18.1.msi [OK]
I've also just tried installing the latest stable 0.20.3 and have the same issue. I initially ran as an upgrade, but also tried fresh install. Same issue.
The path D:\c\ looks like a mix of linux and windows paths.
Maybe there us a regression somewhere
Same issue when trying to update/clean install from 0.21.3:
$ yarn -V
module.js:471
throw err;
^
Error: Cannot find module 'C:\c\Program Files (x86)\Yarn\bin\yarn.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
Still appears to be looking for an invalid path
I ran into the same issue.
I managed to fix it by reverting bin/yarn to
https://github.com/yarnpkg/yarn/blob/e2f5c268862d053d15df798d683c8ad086d7f00d/bin/yarn
I tried other version of the file but they all had the same issue.
The change here https://github.com/yarnpkg/yarn/commit/7fe2e53a59d5c5d256459854dd7ad4d4ff874682
seems to be where this started. It seems specific to Mingw32 though (at least based on it works fine in powershell)
I don't think reverting the file is a good long term solution since there are fixes there for a reason, but at the very least it can shed some light on the cause of the current issue (Mingw32 not handling the basedir variable correctly).
Anyone wants to start a PR with a revert and cc the contributor who added it?
Same issue when installing 0.23.2, had to revert back to 0.18.1
Updating Git Bash to 2.12.2 seems to solve my problem.
Thanks @ratiw , I've just updated Bash to 2.12.2 from 2.7.2, updated Yarn from 0.18.1 to 0.23.2 and no longer get the issue :+1:
Interestingly, I didn't experience this issue on my desktop machine that was running 2.5.0 (I think, certainly and older version to 2.7.2), so it's possible it was introduced around 2.6.x or 2.7.x versions.
Updating Git Bash was also the resolution to another issue I was having on my desktop running Bash 2.5.0 https://github.com/Microsoft/vscode/issues/21885
Definitely worth keeping Git Bash up to date it seems.
This should be fixed in recent versions so closing.
Thanks! @ratiw
Most helpful comment
Updating Git Bash to 2.12.2 seems to solve my problem.