yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.43k stars 1.11k forks source link

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

Open sebastienlabine opened 2 years ago

sebastienlabine commented 2 years ago

Self-service

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

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

H4M5TER commented 2 years ago

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.

sebastienlabine commented 2 years ago

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

sebastienlabine commented 2 years ago

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

b13nxx commented 1 year ago

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?

H4M5TER commented 1 year ago

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

lustef commented 9 months ago

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.

MolinRE commented 7 months ago

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