Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

npm unlink does not unlink from global path #4005

Closed
defunctzombie opened this issue Oct 17, 2013 · 15 comments
Closed

npm unlink does not unlink from global path #4005

defunctzombie opened this issue Oct 17, 2013 · 15 comments

Comments

@defunctzombie
Copy link

Steps to reproduce:

  1. checkout a node project
  2. cd
  3. npm link
  4. npm unlink

The expected result is to have the project no longer linked globally but alas, unlink says that the project is not installed under its own node_modules folder (and yes, indeed it is not) and doesn't unlink it globally.

@luk-
Copy link
Contributor

luk- commented Oct 17, 2013

unlink is just an alias for uninstall, ala the unix unlink.

@defunctzombie
Copy link
Author

So how would you undo the npm link then? (Outside of digging up the symlink
stuff manually)
On Oct 17, 2013 12:27 PM, "Luke Arduini" notifications@github.com wrote:

unlink is just an alias for uninstall, ala the unix unlink.


Reply to this email directly or view it on GitHubhttps://github.com/isaacs/npm/issues/4005#issuecomment-26523909
.

@luk-
Copy link
Contributor

luk- commented Oct 17, 2013

You can npm r [module] -g but afaik there isn't a more elegant way than that.

@defunctzombie
Copy link
Author

good enough for me

@mgol
Copy link

mgol commented Mar 13, 2014

This seems very unintuitive. unlink should undo an action of link, that's what its name suggests.

@neverfox
Copy link

Exactly, @mzgol.

niksy added a commit to niksy/dotfiles that referenced this issue Jun 11, 2014
niksy added a commit to niksy/dotfiles that referenced this issue Jun 11, 2014
isaacs added a commit that referenced this issue Sep 22, 2014
Fix #4005 #6248

What's interesting is that the comment in the code seems to indicate
that this was *always* the intent.  But somewhere along the line, that
seems to have broken.

This makes 'npm link' be un-done by running 'npm unlink'.
@othiym23
Copy link
Contributor

Reopening this, as I agree that this is a confusing inconsistency in the CLI, but be forewarned that it's very low priority and won't be happening for a while. Also you can stop +1ing it now, thanks.

@othiym23
Copy link
Contributor

...actually, @isaacs put together a patch to make npm rm \ npm r \ npm unlink, when called without arguments, do exactly what most of you have been asking for. Since all it needs is a test, it can probably be landed relatively soon.

@isaacs isaacs closed this as completed in 7bf85cc Feb 27, 2015
@othiym23
Copy link
Contributor

Fixed in 7bf85cc. Thanks for your patience, everybody.

@markplewis
Copy link

I don't know if this is the best place to raise this, but here goes:

The NPM Link documentation provides an example of how to link a package:

cd ~/projects/node-redis    # go into the package directory
npm link                    # creates global link
cd ~/projects/node-bloggy   # go into some other package directory
npm link redis              # link-install the package

But it doesn't show you how to unlink a package. May I suggest adding the following?

cd ~/projects/node-bloggy  # go into some other package directory
npm unlink redis           # unlink-uninstall the package
npm install redis          # re-install the package
cd ~/projects/node-redis   # go into the package directory
npm unlink                 # deletes global link

@rohan-deshpande
Copy link

This isn't working for me. I created a package locally and linked it globally for testing, now I cannot unlink it.

I've tried

cd ~/myPackage
npm unlink

and npm r myPackage -g

But if I

cd /usr/local/lib/node_modules
ls -la

I can still see that myPackage is symlinked. Can I just delete the symlink?

@ericnewton76
Copy link

ericnewton76 commented Apr 14, 2017

@rohan-deshpande i'm seeing the same thing. npm unlink [package] and the package script files to execute the package still exist globally

I'm on windows, so npm unlink is not removing from %USERPROFILE%\AppData\roaming\npm\ [package].cmd and [package] script, and the NTFS junction at node_modules\[package] to the actual package files still exists.

Very unexpected after calling npm unlink [package] and not seeing any errors.

@kerryChen95
Copy link

Post how to link & unlink scoped packages, which work for me on mac at least. May it helps someone.

Link scoped pakcages:

cd ~/projects/node-redis    # go into the scoped package directory
npm link                    # creates global link
cd ~/projects/node-bloggy   # go into some other package directory
npm link @myorg/redis       # link-install the scoped package

Unlink scoped packages:

cd ~/projects/node-bloggy  # go into some other package directory
npm unlink @myorg/redis    # unlink-uninstall the scoped package
npm install @myorg/redis   # re-install the scoped package
cd ~/projects/node-redis   # go into the scoped package directory
npm unlink                 # deletes global link

@edvinkuric
Copy link

edvinkuric commented Mar 21, 2018

I also have the same Issue when using npm link.
Both my Projects (parent/sub) have the typescript-dependency, which cause the "Duplicate Identifier"-error.

I also use:
-) Windows 10 / Windows Server 2012 R2
-) nvm (to manage the node versions)
-) Typescript 2.7.1 ( both versions )

when using npm unlink, the symlink doesn't get removed from the specified alias of nodejs.

Even after switching the nodejs via nvm, the error still occurs.

Haven't figured out yet, which file i need to delete.

Some errors of that:
node_modules/typescript/lib/typescriptServices.d.ts(2546,9): error TS2300: Duplicate identifier 'Iterator'. node_modules/typescript/lib/typescriptServices.d.ts(2547,9): error TS2300: Duplicate identifier 'NoAsciiEscaping'. node_modules/typescript/lib/typescriptServices.d.ts(2556,9): error TS2300: Duplicate identifier 'SourceFile'. node_modules/typescript/lib/typescriptServices.d.ts(2557,9): error TS2300: Duplicate identifier 'Expression'. node_modules/typescript/lib/typescriptServices.d.ts(2558,9): error TS2300: Duplicate identifier 'IdentifierName'. node_modules/typescript/lib/typescriptServices.d.ts(2559,9): error TS2300: Duplicate identifier 'MappedTypeParameter'. node_modules/typescript/lib/typescriptServices.d.ts(2560,9): error TS2300: Duplicate identifier 'Unspecified'. node_modules/typescript/lib/typescriptServices.d.ts(2641,10): error TS2300: Duplicate identifier 'TransformerFactory'. node_modules/typescript/lib/typescriptServices.d.ts(2645,10): error TS2300: Duplicate identifier 'Transformer'. node_modules/typescript/lib/typescriptServices.d.ts(2649,10): error TS2300: Duplicate identifier 'Visitor'. node_modules/typescript/lib/typescriptServices.d.ts(2650,10): error TS2300: Duplicate identifier 'VisitResult'. node_modules/typescript/lib/typescriptServices.d.ts(2745,9): error TS2300: Duplicate identifier 'None'. node_modules/typescript/lib/typescriptServices.d.ts(2746,9): error TS2300: Duplicate identifier 'SingleLine'. node_modules/typescript/lib/typescriptServices.d.ts(2747,9): error TS2300: Duplicate identifier 'MultiLine'. node_modules/typescript/lib/typescriptServices.d.ts(2748,9): error TS2300: Duplicate identifier 'PreserveLines'. node_modules/typescript/lib/typescriptServices.d.ts(2749,9): error TS2300: Duplicate identifier 'LinesMask'. node_modules/typescript/lib/typescriptServices.d.ts(2750,9): error TS2300: Duplicate identifier 'NotDelimited'. node_modules/typescript/lib/typescriptServices.d.ts(2751,9): error TS2300: Duplicate identifier 'BarDelimited'. node_modules/typescript/lib/typescriptServices.d.ts(2752,9): error TS2300: Duplicate identifier 'AmpersandDelimited'. node_modules/typescript/lib/typescriptServices.d.ts(2753,9): error TS2300: Duplicate identifier 'CommaDelimited'. node_modules/typescript/lib/typescriptServices.d.ts(2754,9): error TS2300: Duplicate identifier 'DelimitersMask'. node_modules/typescript/lib/typescriptServices.d.ts(2755,9): error TS2300: Duplicate identifier 'AllowTrailingComma'. node_modules/typescript/lib/typescriptServices.d.ts(2756,9): error TS2300: Duplicate identifier 'Indented'. node_modules/typescript/lib/typescriptServices.d.ts(2757,9): error TS2300: Duplicate identifier 'SpaceBetweenBraces'. node_modules/typescript/lib/typescriptServices.d.ts(2758,9): error TS2300: Duplicate identifier 'SpaceBetweenSiblings'. node_modules/typescript/lib/typescriptServices.d.ts(2759,9): error TS2300: Duplicate identifier 'Braces'. node_modules/typescript/lib/typescriptServices.d.ts(2760,9): error TS2300: Duplicate identifier 'Parenthesis'. node_modules/typescript/lib/typescriptServices.d.ts(2761,9): error TS2300: Duplicate identifier 'AngleBrackets'. node_modules/typescript/lib/typescriptServices.d.ts(2762,9): error TS2300: Duplicate identifier 'SquareBrackets'. node_modules/typescript/lib/typescriptServices.d.ts(2763,9): error TS2300: Duplicate identifier 'BracketsMask'.

@vadimshvetsov
Copy link

I had some packages npm linked before.
After npm unlink -g or aliased npm rm -g they weren't removed.
Then I've moved inside global node_modules directory for removing symlinks directly and they're gone.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests