npm / npm

This repository is moving to: https://github.com/npm/cli

Home Page:http://npm.community

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm unlink does not unlink from global path

defunctzombie opened this issue · comments

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.

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

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
.

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

good enough for me

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

Exactly, @mzgol.

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.

...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.

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

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

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?

@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.

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

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'.

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.