JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27495
  • Score
    100M100P100Q145882F
  • License MIT

A better npm link

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (link) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    npx link

    A safer version of npm link.

    Why is npm link unsafe? Read the blog post.

    Features

    • 🔗 Link dependencies without removing previous links
    • 🛡 Only resolves to local paths
    • 🔥 Config file quickly linking multiple packages
    • 💫 Deep linking for quickling linking multilple packages

    Premium sponsor banner

    Usage

    npx link simply symlinks the target package as a dependency in the current project.

    Unlike npm link, it doesn't install the target package globally or re-install project dependencies.

    From the project you want to link a package to:

    npx link <package-path>

    Configuration file

    Create a link.config.json (or link.config.js) configuration file at the root of your npm project to automatically setup links to multiple packages.

    Example link.config.json:

    {
        "packages": [
            "/path/to/package-path-a",
            "../package-path-b"
        ]
    }

    The configuration has the following type schema:

    type LinkConfig = {
    
        // Whether to run link on linked packages with link.config.json
        deepLink?: boolean
    
        // List of packages to link
        packages?: string[]
    }

    Note: It's not recommended to commit this file to source control since this is for local development with local paths.

    To link the dependencies defined in link.config.json, run:

    npx link

    Deep linking

    By default, npx link only links packages in the current project. However, there are cases where the linked packages also needs linking setup.

    Deep linking recursively runs link on every linked package that has a link.config.json file.

    Enable with the --deep flag or deepLink property in link.config.json.

    npx link --deep

    Premium sponsor banner

    FAQ

    Because npm link has footguns that make it dangerous to use.

    Run npm install (or the equivalent in your preferred package manager) and it should remove them.

    You must use npx v7 or higher. Check the version with npx -v.

    In the obsolete npx v6, local binaries take precedence over npm modules so npx link can point to the native link/ln command:

    $ npx link
    usage: ln [-s [-F] | -L | -P] [-f | -i] [-hnv] source_file [target_file]
           ln [-s [-F] | -L | -P] [-f | -i] [-hnv] source_file ... target_dir
           link source_file target_file

    To work around this, install link globally first:

    $ npm i -g link
    $ npx link

    Sponsors

    Premium sponsor banner Premium sponsor banner