Replies: 2 comments
-
|
Good question! The two-step design of npm link is mostly about flexibility and reuse. The first step creates a global reference to your local package, so you can link the same package into multiple projects without having to point to a specific filesystem path every time. This also better matches how npm normally works (packages come from a central place, then get installed into projects), which helps catch issues with package config and resolution. It also avoids fragile relative paths and handles cross-platform differences (Windows/macOS/Linux) more safely. So while linking directly to a local folder could work in theory, the global step makes the workflow more reusable, portable, and closer to real-world usage. |
Beta Was this translation helpful? Give feedback.
-
|
If it were one step, running it in your library folder would instantly break every other project on your computer that uses that package name. The split gives you control over exactly which apps use the dev version. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
I understand npm link first create a synlink in global folder reference local package,then create a symlink in your project.But why not just create a symlink in your project directly?Is there any reason for this?
Beta Was this translation helpful? Give feedback.
All reactions