Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

366
Views
Do npm/yarn/yarn2/pnpm fetch package.json first, for parsing "os" field?

There is os field in package.json.

So, do npm/yarn/yarn2/pnpm fetch dependency's pacakge.json first, then parse the "os" field(if exists), and download the source code only if os matches?

Or, do they just download every content (package.json+source) just all at once?

Context I am planning to publish a package that includes some os-specific code(compiled by go). So I have 3 compiled binaries (for windows, linux, macOS). However, each of them has a large size. Thus I want to avoid naively include them all in one package. Hence, I am thinking of separating them like @foo/win32, @foo/linux, @foo/darwin. Then letting a package named foo depend on all of them. And eventually, users install npm install foo without caring about their os. Will this separation avoid installing unnecessary dependency? For example, when npm install foo on linux, I want npm not to install @foo/win32, @foo/darwin under the hood.

Thanks.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!