9

I bashed my head against the wall trying to install a local package using Yarn v3. Here all the things I tried:

  1. Run yarn add file:../hardhat-packager
  2. Run yarn add ../hardhat-packager
  3. Manually add "hardhat-packager": "file:../hardhat-packager" in package.json
  4. Manually add "hardhat-packager": "../hardhat-packager" in package.json

All of the above resulted in Yarn getting stuck at the installation step, as shown in the screenshot below. I waited more than five minutes and I made sure that my Internet connection is fast.

I know that there is an option to link a package, but that is not quite white I want. I don't want symlinks, I want the actual package files copied over.

How can I do this? I'm using Yarn v3.2.0

Yarn Stuck

Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114
  • https://classic.yarnpkg.com/lang/en/docs/cli/add/ - yarn docs show multiple options for installing packages from different locations – Ross Mar 29 '22 at 14:43
  • @Ross those are the docs for Yarn classic (v1), my question is about Yarn v3. – Paul Razvan Berg Mar 29 '22 at 14:44
  • True, it doesn't seem yarn add has changed in v3, though the docs don't specifically mention adding a local file. It does appear the 'yarn init' docs may give you what you need - it creates/installs a package in a local directory - https://yarnpkg.com/cli/init – Ross Mar 29 '22 at 15:47
  • also `yarn add -h`, although not super helpful in this case :( – James Gentes May 28 '23 at 15:03

1 Answers1

9

To install local package for Yarn 3 you should use pattern packagename@location.

For an example:

yarn add hardhat-packager@file:../hardhat-packager

or if you have made tarball with yarn pack it should look like:

yarn add hardhat-packager@file:../some_path/hardhat-packager-v0.1.0.tgz 
Rob
  • 483
  • 5
  • 11