Nvm: Can't uninstall version if lib/node_modules contain a symlink

Created on 24 Oct 2016  路  5Comments  路  Source: nvm-sh/nvm

Environment:

  • nvm version: latest
  • shell: zsh

When doing local module development, you'd sometimes run the npm link command with is kind of like installing the module you're working on globally. But instead of actually copying the bin files it just creates a symlink to your code.

If I then try to run nvm uninstall <x> the uninstaller will fail with the following message:

% nvm uninstall 4.4                              
file is not writable: $NVM_DIR/versions/node/v4.4.5/lib/node_modules/test-all-versions/.git/objects/01/0300c6d46fc154cec38182e38713bed887a6c7
Cannot uninstall, incorrect permissions on installation folder.
This is usually caused by running `npm install -g` as root. Run the following commands as root to fix the permissions and then try again.

  chown -R watson "$NVM_DIR/versions/node/v4.4.5"
  chmod -R u+w "$NVM_DIR/versions/node/v4.4.5"

The issue is not resolved by running the two commands and a peak inside $NVM_DIR/versions/node/v4.4.5/lib/node_modules shows you:

% ls -l $NVM_DIR/versions/node/v4.4.5/lib/node_modules 
total 8
drwxr-xr-x   8 watson  staff  272 Jun  7 10:37 airtar
drwxr-xr-x   9 watson  staff  306 Jun  5 11:20 bcc
drwxr-xr-x  13 watson  staff  442 Aug 30 17:18 coffee-script
drwxr-xr-x  16 watson  staff  544 May 26 16:43 dat
drwxr-xr-x   7 watson  staff  238 Jul  7 23:00 geo-legacy
drwxr-xr-x  11 watson  staff  374 Jun  3 21:53 geopkg
drwxr-xr-x   8 watson  staff  272 May 27 09:40 git-ps1
drwxr-xr-x   6 watson  staff  204 Jun 30 14:53 greenkeeper
drwxr-xr-x  12 watson  staff  408 Jun 12 04:07 gulp
drwxr-xr-x   9 watson  staff  306 Jun 16 21:47 http-traceroute
drwxr-xr-x  15 watson  staff  510 Jul  2 13:43 ipp-printer
drwxr-xr-x  19 watson  staff  646 Jul  1 21:54 node-inspector
drwxr-xr-x  18 watson  staff  612 Jul 20 15:59 nodemon
drwxr-xr-x  23 watson  staff  782 May 24 19:30 npm
drwxr-xr-x  11 watson  staff  374 Jun  5 10:49 npm-available
drwxr-xr-x  11 watson  staff  374 Jun 23 20:18 peerflix
drwxr-xr-x  18 watson  staff  612 Aug 24 17:36 standard
drwxr-xr-x  24 watson  staff  816 Jun  5 09:37 t2-cli
lrwxr-xr-x   1 watson  staff   49 Jun 19 06:53 test-all-versions -> /Users/watson/code/node_modules/test-all-versions

If I instead manually remove the symlink:

% rm $NVM_DIR/versions/node/v4.4.5/lib/node_modules/test-all-versions 

Then the uninstall is able to complete

bugs uninstalling

Most helpful comment

Thanks for the report! I've recently run into the same issue, and I'm working on a fix locally as we speak. (Manually running npm unlink -g also resolves it)

All 5 comments

Thanks for the report! I've recently run into the same issue, and I'm working on a fix locally as we speak. (Manually running npm unlink -g also resolves it)

@ljharb Is there a risk that it's trying to delete the data inside my code folder by following the symlink? E.g. do you know if it might have deleted some data in there before getting the error mentioned above?

No, the point of that error is that nothing is deleted until it passes. In addition, it wouldn't have removed the symlink contents, just the link itself, so your data is safe.

Just encountered this problem. Guessing I'm on a version of nvm without the fix: 0.31.7 @ljharb?

Manually removed the symlinks as suggested by @watson in original comment and nvm uninstall ran fine 馃挴

@chowdhurian either way you should update to v0.33.11 - specifically tho, the fix is in v0.33.9, as you can see from the commit

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cdelorme picture cdelorme  路  5Comments

Kunepro picture Kunepro  路  5Comments

tongxiaofeng picture tongxiaofeng  路  5Comments

gsklee picture gsklee  路  4Comments

pixelchutes picture pixelchutes  路  3Comments