Yarn: Problem with har-validator after reinstall

Created on 8 Mar 2017  Â·  10Comments  Â·  Source: yarnpkg/yarn

I've just reinstalled yarn 0.21.3 on Windows, and I'm seeing an error when I try to run a yarn upgrade on my project...

> yarn upgrade
yarn upgrade v0.21.3
[1/4] Resolving packages...
error An unexpected error occurred: "ENOENT: no such file or directory, open 'C:\\Users\\(...)\\AppData\\Roaming\\npm\\node_modules\\yarn\\node_modules\\har-validator\\lib\\index.js'".

Indeed, a file doesn't exist at that path, but the main file for the module (from its package.json) is lib/node4/promise.js. If I create an lib/index.js file with the content module.exports = require('./node4/promise.js'); then it all works again.

Not sure if I should class this as a problem with yarn, or this har-validator module?

Most helpful comment

I'm on latest Node, which is 7.7.2 and I had that issue. Installing Yarn 0.22.0 RC fixed the issue. Hopefully, they will released that version soon. For those who can't wait, just do the following :

npm -g install [email protected]

That fixed my problem and everything is now working normally.

All 10 comments

I had this problem with [email protected] after upgrading to Node 7.7.1. I have no problems with [email protected] on Node 7.7.1, nor [email protected] on Node 6.10.0.

It seems to be triggered by upgrading to har-validator 4.x.

Hi, so I had this issue on Monday morning and it's a Yarn dependency 'request' that updated over the weekend. Yarn has this dependency as ^2.75.0 so it would of grabbed the latest version, breaking it (for some reason I do not know).

I found this problem mostly with using 'npm install -g yarn'. The only solution that I managed to get around it was by using the 'exe/msi' installer of yarn and it finally worked, if that's of any use.

Using Node 7 and yarn 0.21.3

I updated to Node 7 and that didn't work by itself. I also had to update yarn to the release candidate v0.22.0. Not sure if just updating to [email protected] would do it without the Node update so that might be a better first step.

We're also affected by this bug. As we have multiple nodejs versions running on one machine (think of nvm) we also want to have a defined yarn version _per nodejs version_. Using the provided packages (e.g. .deb) or the curl … install.sh method are incompatible to this approach as they enforce _a single, global yarn version_ to be used.

I'm wondering why lib/index.js is located by yarn when package.json of har-validator 4.x was updated with new main entry.

In lib/har.js of yarn v0.21.3,
var validate = require('har-validator')
There is no problem with this code line, but what causes this bizarre issue?

I would also like to note I've had bizarre issues like this, and I don't know if its a separate issue. But that 'har-validator' package is often missing the 'index.js' file .

This is happened to me in my own project and sometimes Yarn just randomly misses a few files from the dependencies listed. We often have to copy over the files from the cache into node_modules to solve the issue.

Looks like har-validator is doing the exact same thing.

experiencing the same issue after re-installing yarn via npm install -g on windows.

I'm on latest Node, which is 7.7.2 and I had that issue. Installing Yarn 0.22.0 RC fixed the issue. Hopefully, they will released that version soon. For those who can't wait, just do the following :

npm -g install [email protected]

That fixed my problem and everything is now working normally.

Should be fixed by now, I'm going to close this issue. Feel free to reopen it if you still experience this issue.

Was this page helpful?
0 / 5 - 0 ratings