npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

resolve-symlinks

v0.0.5

Published

Resolve issues with locally installed packages

Downloads

9

Readme

resolve-symlinks

Usage

npx resolve-symlinks

Why this exists

When you install package using npm/yarn locally (npm i ./path/to/package) it actually links your package to .config/yarn/link/<package-name> first, and only then to your node_modules folder.

So, if you have 2 folders with locally installed packages with the same name in package.json, the first package you install will be linked to global directory, second one will use link from first package.

The following diagram might help understanding the situation:

Because of that your dev-servers might not work as expected (reload on safe) since your are saving files in one project, while the package is actually linked to other directory.

How it works

The whole source code is about 200 lines of code, when it runs it does the following things:

  1. Checks if package.json even exists. Exits if it does not.
  2. Loads data from package.json. Checks if dependencies field exists and is of type object. Exits if it is not.
  3. Checks if node_modules exists. If they do not exist, runs a prompt to install dependencies using npm i command. (can be changed later)
  4. Filters dependencies to process only locally installed ones.
  5. Checks if packages exists. If they do not, exits.
  6. Checks if packages exists in node_modules folder. If they do not, exits.
  7. Loads real paths of locally installed dependencies.
  8. Filters dependencies to process only those which are installed from incorrect path. Aka, the whole idea of this package.
  9. If there are any, logs them in the console and prompts to fix them.
    If you want to fix them, this package will do the following:
  10. Unlink package from ./config/yarn/link/<package-name>.
  11. Unlink package from node_modules.
  12. Link package into ./config/yarn/link/<package-name>
  13. Link global package into node_modules/<package-name>
    If not, will end the process.

That is it.