Skip to content

Add name field to package.json to fix Yarn v2+ compatibility issue #62

@Skanislav

Description

@Skanislav

While trying to set up the CoW Swap repo locally and installing this package as a dependency I encountered the following error when running yarn install:

Packing @cowprotocol/ethflowcontract@https://github.com/cowprotocol/ethflowcontract.git#commit=9797105dfa25330a2e88cc4180df0fc34cf8fbbd from sources
Using Yarn Classic for bootstrap. Reason: "__metadata" key not found in yarn.lock, must be a Yarn classic lockfile

➤ YN0000: Retrieving https://classic.yarnpkg.com/latest.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-1.22.22.cjs
➤ YN0000: Done in 1s 800ms

yarn install v1.22.22
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 6.06s.

yarn pack v1.22.22
error Package doesn't have a name.
info Visit https://yarnpkg.com/en/docs/cli/pack for documentation about this command.

My local Yarn version was 3.6, and switching to Yarn v1.22 fixed the problem.

The key difference seems to be that starting from Yarn v2, Yarn actually packs dependencies, which requires a valid name field in package.json. Yarn v1 is more lenient and doesn’t enforce this.

Adding the missing name field isn’t critical right now but would make the package more future-proof

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions