-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] npm no longer creating symlinks for local package installations #6033
Comments
When you install a package locally using the However, the package is not created as a symbolic link in the To create a symbolic link to a locally installed package, you must use the However, there are a few possible reasons why the npm link command might not be creating a symbolic link to the package. Here are some things to check:
Check if the Node.js global symlinks directory is corrupted or if an error occurred while creating the symbolic link. You can try deleting the global symlinks directory and running the If you continue to have problems creating a symbolic link with the npm link command, try including the --force argument on the command line to force creation of the symbolic link. This can be useful if the symbolic link already exists and is corrupted. I hope this helps! |
it seems this issue breaks my project. |
I can confirm this behavior and it also breaks our projects. |
Chiming in with the observation that symlink imports are treated differently from non-symlink imports by TypeScript, which can cause confusing errors. |
This was a change from npm 8 -> npm 9. This behavior is controlled by the Note that workspaces will always be symlinked, so the latest workspaces changes will always be reflected in your package. How to turn it off You can run the following to set the previous behavior on a per-project basis:
|
I can confirm that this workaround works. But would prefer it to be documented in some form of migration document. |
@whirledsol good call, I'll add more info on this to v9 FAQ tracking issue #5844 |
While I can try to remember to use "npm link" instead of "npm install", when I'm reinstalling a package using "npm install" on an existing package.json there is no information about which entries are supposed to be symlinks. There needs to be a way to preserve the nature of each installed module. What is the reason for this change? When debugging it's very valuable to share the code for the modules in a workspace ... and I'm always debugging |
@BobFrankston Are you using npm
This is a good point and I'm investigating what |
I was referring to workspaces in VSC. I wasn't aware of npm workspaces, so will try to learn more. The symlinks were working well enough (especially with preserve-symlinks in node) so I didn't search further. But using npm link may work well enough for now. I appreciate the challenge of compatibility with tools that don't preserve side properties. And, I also find the copying functionality useful for some of my use cases. |
First, I do have a use case for linking -- I generate JS (OK, TS) class definitions for SQL database files. I want to have the latest definitions available in each application. (I deleted my other comment because some of the problems seem to have been a side-effect of system problems) |
It seems the change has been reverted ... it's now back to installing as links. I did find the new behavior useful so it would be nice to have the copying as an option under a flag. I found that out when trying to track down a problem with links> I have
with
When I do
I get
but if I use WSL and then run the command, it works just fine. It seems there is a problem in expanding links in Windows but not in Linux. Fortunately, I presume it is a simple bug, but I don't know where to start looking. I am going to investigate more to see if there is any other reason for the problem. |
@BobFrankston you can set it to whichever behavior you like in npm 8 or 9 with |
Thanks -- but that still leaves the issue of resolution bugs in Windows that don't happen in Linux |
Case in point. [npm 9.4.2] In Windows
In WSL
works fine |
@BobFrankston interesting, would you be able to open a new issue for that specifically? seems like a different bug that was maybe highlighted with |
FIled it as #6178. It seems to be related to links. |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
currently when I install a local package, a symlink is not being created
Expected Behavior
I expect a symlink to be created for locally installed packages so I don't have to rebuild just to see changes during dev
Steps To Reproduce
I have installed a local npm package via:
npm i ./my_modules/mypackage
It shows up in my dependencies as:
when I look at the
node_modules
folder, it shows up in there as well, but it is not symlinkedthere is no arrow icon in the explorer indicating it is symlinked
which means I have to rebuild every single time I want to see changes inside the local package
this only just started happening today, I'm not sure why it's not symlinking all of the sudden
how do I resolve this issue so that it symlinks properly? it used to do this automatically and now it isn't. I've even tried re-installing everything on my dev machine and it is still doing this behaviour.
normally when I install a local npm package it will symlink it properly, automatically
now, for whatever reason, it is not symlinking
I've even tried using
npm link
still doesn't symlink.
Environment
The text was updated successfully, but these errors were encountered: