yarn icon indicating copy to clipboard operation
yarn copied to clipboard

Weird problem with installation

Open MRokas opened this issue 10 years ago • 9 comments

Do you want to request a feature or report a bug? Report a bug

What is the current behavior?

rokas@ROKAS ~/dev/verse
$ yarn add @types/react -dev
yarn add v0.15.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency
└─ @types/[email protected]
Done in 0.89s.

# at this point node_modules has @types/react

rokas@ROKAS ~/dev/verse
$ yarn add @types/react-dom -dev
yarn add v0.15.1
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
error ENOENT: no such file or directory, open 'C:\Users\rokas\dev\verse\node_modules\@types\react-dom\index.d.ts'
    at Error (native)
info Visit http://yarnpkg.com/en/docs/cli/add for documentation about this command.

# at this point node_modules is empty

$ yarn add @types/react-dom @types/react -dev
yarn add v0.15.1
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 2 new dependencies.
├─ @types/[email protected]
└─ @types/[email protected]
Done in 2.25s.

# at this point it has both of them

rokas@MAZIAI ~/dev/verse
$ yarn add react react-dom
yarn add v0.15.1
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
error ENOENT: no such file or directory, open 'C:\Users\rokas\dev\verse\node_modules\@types\react\index.d.ts'
    at Error (native)
info Visit http://yarnpkg.com/en/docs/cli/add for documentation about this command.

# at this point @types is gone, it has react/react-dom and their dependencies, however none has package.json

If the current behavior is a bug, please provide the steps to reproduce.

yarn add @types/react @types/react-dom -dev
yarn add react react-dom

What is the expected behavior? It shouldn't clear

Please mention your node.js, yarn and operating system version. [email protected] [email protected] Windows7 64bit

MRokas avatar Oct 11 '16 17:10 MRokas

Seems like there's something specific to Windows happening here, I can only repro on Windows but not Linux.

On Windows:

C:\temp\yarntest
λ c:\src\yarn\bin\yarn add @types/react @types/react-dom -dev
yarn add v0.15.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 2 new dependencies.
├─ @types/[email protected]
└─ @types/[email protected]
Done in 1.14s.

C:\temp\yarntest(<invalid_name>@<invalid_version>)
λ c:\src\yarn\bin\yarn add react react-dom
yarn add v0.15.0
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
error ENOENT: no such file or directory, open 'C:\temp\yarntest\node_modules\@types\react\index.d.ts'
    at Error (native)
info Visit http://yarnpkg.com/en/docs/cli/add for documentation about this command.

On Debian Linux:

10:41 daniel@dan /tmp/yarntest
% /usr/local/src/yarn/bin/yarn add @types/react @types/react-dom -dev
yarn add v0.15.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 2 new dependencies.
├─ @types/[email protected]
└─ @types/[email protected]
Done in 2.90s.

10:42 daniel@dan /tmp/yarntest
% /usr/local/src/yarn/bin/yarn add react react-dom
yarn add v0.15.0
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 17 new dependencies.
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 8.67s.

Daniel15 avatar Oct 11 '16 17:10 Daniel15

+1 For me it always works at a second try. But still pls fix.

Lichthagel avatar Oct 23 '16 12:10 Lichthagel

Same problem here, but it's always a different file under \@types\. Retrying the command also doesn't work, it's still throwing that error.

flagbug avatar Dec 01 '16 11:12 flagbug

Same here -- while it will very often work the 2nd time, another run after that very often fails.

eamodio avatar Dec 03 '16 07:12 eamodio

I had similar issue with local packages: "package": "file:./../../package/dir" on Linux Mint LMDE. Each run resulted in different missing file.

An unexpected error occurred: "ENOENT: no such file or directory,
 open '/home/user/.cache/yarn/v1/npm-package-dir-0.9.0/src/index.js'".

where package-dir was package-name and package resides under ./../../package/dir.

Update: [email protected] [email protected]

jodator avatar Apr 11 '17 14:04 jodator

We need to confirm this with the latest Yarn version.

BYK avatar Oct 26 '17 16:10 BYK

I still get this issue often, with the Yarn 1.2.1 + macOS 10.13 + Node v6.11.3. I've tried for a long time to come up with steps to reproduce, but it seems to happen completely randomly for me.

I'll do a yarn add jquery, for example. During the linking step, it will sometimes throw an error saying that some dependency of some other dependency (completely unrelated to jquery) doesn't exist.

While it seems to happen randomly, the ansi-styles package is a common "missing file" that I see in my error messages.

[3/4] 🔗  Linking dependencies..
error An unexpected error occurred: "ENOENT: no such file or directory, open '/path/to/app/node_modules/@someScope/some-dep/node_modules/ansi-styles/index.js'".

Running the same exact yarn add command again will often fix it. Sometimes it throws the same ENOENT error, but with a different file... and I just end up running yarn add until it works. Sometimes it works on the first try, sometimes on the second, sometimes on the third, etc...

When it finally does work, the file that it originally errors on (ansi-styles/index.js) still isn't there, but apparently it's no longer an issue for it?

I've seen this issue across multiple projects using completely independent lists of dependencies. Doing the same exact thing on a project will sometimes trigger this, and sometimes not, in seemingly identical environments.

This may be a complete red herring, but it seems to happen more when my internet traffic is higher, and always with a yarn linked package in the error message.

mderoche avatar Oct 26 '17 20:10 mderoche

i had this problem..how to solve this mine windows 7 32 bit C:\xampp\htdocs\project>yarn install yarn install v1.3.2 [1/4] Resolving packages... events.js:160 throw er; // Unhandled 'error' event ^

Error: This socket is closed at WriteStream.Socket._writeGeneric (net.js:679:19) at WriteStream.Socket._write (net.js:730:8) at doWrite (_stream_writable.js:331:12) at writeOrBuffer (_stream_writable.js:317:5) at WriteStream.Writable.write (_stream_writable.js:243:11) at WriteStream.Socket.write (net.js:657:40) at Console.warn (console.js:51:16) at C:\Program Files\Yarn\lib\cli.js:73181:5 at Array.forEach (native) at EventEmitter. (C:\Program Files\Yarn\lib\cli.js:73174:24)

C:\xampp\htdocs\project>yarn -v 1.3.2

C:\xampp\htdocs\project>npm -v 3.10.10

hazasaad avatar Nov 16 '17 10:11 hazasaad

Going to close this unless someone can confirm it's still an issue. If so, will reopen

olingern avatar Jan 27 '20 09:01 olingern