Skip to content

optional dependency long should actually be required #314

@aruniverse

Description

@aruniverse

🐛 Bug Report

I am using fastify in a repo with yarn v2 (berry) and using the zero-install feature which is stricter with dependency management.

During compilation i get the following error:

(node:1536) [MODULE_NOT_FOUND] Error: debug tried to access supports-color (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.
 > pnp:C:\Users\ArunG\Repos\GH\gazo\.yarn\cache\fast-json-stringify-npm-2.5.3-5f61461930-b6d1204da2.zip\node_modules\fast-json-stringify\index.js:15:19: error: [@yarnpkg/esbuild-plugin-pnp] fast-json-stringify tried to access long, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: long (via "long")
Required by: fast-json-stringify@npm:2.5.3 (via C:\Users\ArunG\Repos\GH\gazo\.yarn\cache\fast-json-stringify-npm-2.5.3-5f61461930-b6d1204da2.zip\node_modules\fast-json-stringify\index.js)

    15 │   isLong = require('long').isLong

Saw fast-json-stringify was a sub dep of fastify
image

I see you guys try to handle this with the try catch block but i think itd be easier if you guys had a direct dependency on the long package
image
image

I was able to get around this issue using a feature in berry to correct dependencies, see, but thought of raising this issue as more and more users will start using pnp.

To Reproduce

Steps to reproduce the behavior:
If you need a sample to reproduce this, let me know.

Proposal

Move long from being a devDep to a direct dep.

Your Environment

  • node version: 12.16.2
  • fastify version: ^3.12.0
  • os: Windows,
  • yarn: 2.4.1

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