From fbd966b9d8e3482423f7db9c5787df95ffb7f8e6 Mon Sep 17 00:00:00 2001 From: John Gee Date: Fri, 3 Nov 2017 17:12:34 +1300 Subject: [PATCH] Remove existing npm folder before copying activated version --- bin/n | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/n b/bin/n index fc2bac74..2cad36cd 100755 --- a/bin/n +++ b/bin/n @@ -484,7 +484,14 @@ activate() { check_current_version if test "$version" != "$active"; then local dir=$BASE_VERSIONS_DIR/$version - for subdir in bin lib include share; do + # Remove old npm to avoid potential issues with simple overwrite. + if test -d "$dir/lib/node_modules/npm"; then + if test -d "$N_PREFIX/lib/node_modules/npm"; then + rm -rf "$N_PREFIX/lib/node_modules/npm" + fi + fi + # Copy (lib before bin to avoid error messages on Darwin when cp over dangling link) + for subdir in lib bin include share; do if test -L "$N_PREFIX/$subdir"; then find "$dir/$subdir" -mindepth 1 -maxdepth 1 -exec cp -fR "{}" "$N_PREFIX/$subdir" \; else