yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒

Home Page:https://yarnpkg.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug?]: UTF-8 characters in path makes it impossible to use yarn on windows

sebastienlabine opened this issue · comments

Self-service

  • I'd be willing to implement a fix

Describe the bug

Executing a script inside a path that has a UTF-8 character fails with error MODULE_NOT_FOUND.

PS C:\Users\Sébastien Labine\Documents\Github\smartbills\apps\mobile> yarn start
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'C:\Users\S├®bastien Labine\Documents\Github\smartbills\apps\mobile\node_modules\expo\bin\cli.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

As soon as I move my project to the C:/, everything works fine.

PS C:\smartbills> yarn start

To reproduce

  • Create a yarn project on a windows computer with UTF-8 characters in the username.
  • Add any command as script that requires a node_modules to work for instance expo.
expo init my-app
  • try to execute yarn start, it will fail.
  • move folder to c:/
  • try to execute yarn start, it will work.

Environment

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
  Binaries:
    Node: 16.13.2 - C:\Users\SBASTI~1\AppData\Local\Temp\xfs-2c9bae2e\node.CMD
    npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD

Additional context

Multiple other bug report like #3725 reported the same issue

Hi, can you provide your "start" script in package.json?
It seems like yarn was calling another script, but the path it passed to node is corrupted.

@H4M5TER the script called was "expo start". I think the path was corrupted because of the UTF-8 characters "S├®b"

@merceyz I see you mentioned this issue multiple times, do you know if a fix is considered?

commented

Having exactly same issue here. I have UTF-8 characters in my "Desktop" path and I'm not able to fire up "yarn run". It says "MODULE_NOT_FOUND". But I can use other package managers:

image

So... It didn't happen before. Is it something changed?

commented

Check #5319
Patch your own yarn.cjs for a workaround

Hi everyone! I have a similar issue.

I'm using Windows and I have special characters in my username, and I'm trying to run 'yarn create playwright'.
Instead of 'C:\Users\ŁukaszStefański...' I'm getting 'C:\Users\┼üukaszStefa┼äski\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js'
and I'm unable to use the mentioned command.

In the 1809 build of Windows 10 (released about 5 years ago) there is a beta option: Use Unicode UTF-8 for worldwide language support. As of today, it's still in beta, but helped me to solve this issue permanently.
Check this answer: https://superuser.com/a/1435645/250990