2

I want to add a local dependency to package.json`.

Say I have foo-1.0.0.tgz file.

I do

yarn add file:foo-1.0.0.tgz

And for some reason I have this error

➤ YN0027: file:foo-1.0.0.tgz@unknown can’t be resolved to a satisfying range
➤ YN0035: The remote server failed to provide the requested resource
➤ YN0035:   Response Code: 404 (Not Found)
➤ YN0035:   Request Method: GET
➤ YN0035:   Request URL: https://registry.yarnpkg.com/file:foo-1.0.0.tgz
➤ Errors happened when preparing the environment required to run this command.

What I'm doing wrong?

An important notice:

  • I can install this package with npm 8.1.2;
  • If I add the dependency manually to package.json and do yarn install it seems to work. But then I run into problem: if one of the local packages depend on another one yarn fails - couldn't find that dependency. But I guess that issue is out of the scope of the question.

P.S. I'm using yarn 3.1.1 and node v16.13.2

eXception
  • 1,307
  • 1
  • 7
  • 22

1 Answers1

1

I encountered a similar issue today while upgrading to yarn 3.

I think you can get this error when yarn cannot find the file.

In my case, yarn did not like the backslashes in my relative path to the file. (I am running on Windows.) It had worked in yarn 1.x

After I replaced every \ with / in the path, it was able to find and add the package as before.

Ken Lyon
  • 1,230
  • 10
  • 10