npm / npm/rfcs

[RRFC] Allow for use of symlinks to hoist local modules

Open
#382 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
777
Forks
267
PR merge metrics
No merged PRs in 30d

Description

Motivation

Creating a symlink facility from a dependency declaration in a package.json file would go a long way to improve the experience of developers using npm in a monorepo.

Example

My organization develops our Typescript codebase composed of a client, server, and several common packages in a monorepo. Using npm, if I have a file:<my dependent> dependency declared, without running npm link the file is not symlinked in the node_modules directory. This interferes with a number of popular tools, such as React Native, Typescript, Jest, etc when working with monorepos and can make configuration for those tools a headache and reduces the experience of developers working in monorepos.

How
Current Behaviour

Currently using file: in a dependency declaration without running npm link does not create a symlinked local module in the node_modules directory. Consider the following package structure:

- client
    - depends on: common-a, common-b 
- server
    - depends on: common-a
- common-a
- common-b

All modules are written in Typescript. If I run npm install in the necessary order (or with a management tool such as Lerna), the installs will complete successfully. However if I compile common-a and then compile server, the compiler would not be able to find the type definitions of common-a because that module does not exist in the server node_modules directory.

Desired Behaviour

Another dependency specifier could be added (link: would maintain yarn compatibility) to indicate when a true symlink should be created for the dependent local package in the parent node_modules directory. Then tools would be able to find the local module in node_modules as expected.

Willing to implement, will just need guidance on what the relevant parts of the codebase would be.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named in the issue. Begin by locating npm’s handling of file: dependencies and related link/install behavior; done means a declared link: dependency creates a true symlink in the parent node_modules and works for the described monorepo.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.