nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Edgecase for 'nvm is not compatible with the npm config "prefix" option' error

mkarajohn opened this issue · comments

Operating system and version:

MacOS Catalina 10.15.6

nvm debug output:

nvm --version: v0.35.3
$TERM_PROGRAM: Apple_Terminal
$SHELL: /bin/zsh
$SHLVL: 1
${HOME}: /Users/Mitch
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v14.5.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Wireshark.app/Contents/MacOS
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.7.1 (x86_64-apple-darwin19.0)'

nvm ls output:

How did you install nvm?

Install script

What steps did you perform?

What happened?

I was doing a clean install of nvm without any external installations of node or npm, I had made sure 1000% that there were no installations of node or npm prior to the installation of nvm.

When I was installing a node version, after having successfully installed nvm, I would always get a

nvm is not compatible with the npm config "prefix" option: currently set to <PATH>
Run `nvm use --delete-prefix v<VERSION>` to unset it.

Immediately after the message, running the list command would output as if the installation was successful, however running node -v would fail, as if node was not installed.

What did you expect to happen?

For the installation to be successful.

Is there anything in any of your profile files that modifies the PATH?

No.

The issue

Long story short, about a month back I was on MacOS High Sierra. I had to do a clean install of the OS and Catalina was used.
After recreating my user I did a restore from a TimeMachine backup.

Now, I've had this machine since 2015. At that time the OS apparently allowed you to have an account name that started with a capital letter. When I recreated my account on Catalina, I found out that the OS no longer allows to capitalise the username upon account creation.

Thus I ended up with a user mitch instead of Mitch, which is what it was named originally.

When I did the backup restore, my home folder must have been renamed back to "Mitch" from "mitch".

The OS, however, still regarded my home folder path as /Users/mitch, as seen from running echo $HOME and also from looking at the advanced account settings from the System Preferences.

Since the file system I am using is case insensitive, both /Users/mitch and /Users/Mitch work.

After not being able to find a solution to my issue, after having wasted quite a few hours on it, and there was no other installation of npm or node, I decided to change the home directory path from /Users/mitch to /Users/Mitch, as "Mitch" is the actual name of my home directory.

This must have been of importance for nvm, because changing the path from System Preferences, resolved all my issues.

This is a freak-edgecase for this error, but if you'd like I could at least open up a PR which adds a warning that "home directory path is case sensitive" or something like that, or even attempt to adjust the code itself, and offer a code PR.

You're definitely not the first person who's reported that the capitalization of their whoami and of their username in $HOME do not agree, but you are the first one to provide an actual narrative of how that might have possibly happened! :-D

I'd be happy to accept a PR for a documentation section and/or a warning in nvm's output itself in this case instructing users (probably on mac only, for now?) to compare echo $HOME with whoami.

Fixed by #2263.

نظام التشغيل والإصدار:

ماك كاتالينا 10.15.6

nvm debugانتاج:

nvm lsانتاج:

كيف قمت بالتثبيت nvm؟

تثبيت البرنامج النصي

ما الخطوات التي قمت بها؟

ماذا حدث؟

كنت أقوم بتثبيت نظيف لـ nvm دون أي تثبيتات خارجية للعقدة أو npm، وقد تأكدت بنسبة 1000% من عدم وجود تثبيتات للعقدة أو npm قبل تثبيت nvm.

عندما كنت أقوم بتثبيت إصدار عقدة، بعد تثبيت nvm بنجاح، سأحصل دائمًا على ملف

nvm is not compatible with the npm config "prefix" option: currently set to <PATH>
Run `nvm use --delete-prefix v<VERSION>` to unset it.

مباشرة بعد الرسالة، سيؤدي تشغيل listالأمر إلى إخراج الأمر كما لو كان التثبيت ناجحًا، ولكن التشغيل node -vسيفشل، كما لو لم يتم تثبيت العقدة.

ماذا تتوقع أن يحدث؟

لكي يكون التثبيت ناجحا.

هل هناك أي شيء في أي من ملفات ملفك الشخصي يعدل ملف PATH؟

لا.

المشكلة

قصة قصيرة طويلة، منذ حوالي شهر كنت أستخدم نظام التشغيل MacOS High Sierra. اضطررت إلى إجراء تثبيت نظيف لنظام التشغيل وتم استخدام كاتالينا. بعد إعادة إنشاء المستخدم الخاص بي، قمت بالاستعادة من نسخة احتياطية لـ TimeMachine.

الآن، أملك هذا الجهاز منذ عام 2015. في ذلك الوقت، يبدو أن نظام التشغيل سمح لك بالحصول على اسم حساب يبدأ بحرف كبير. عندما قمت بإعادة إنشاء حسابي على Catalina، اكتشفت أن نظام التشغيل لم يعد يسمح باستخدام اسم المستخدم بأحرف كبيرة عند إنشاء الحساب.

وهكذا انتهى بي الأمر مع مستخدم mitchبدلاً من Mitch، وهو الاسم الذي تم تسميته في الأصل.

عندما قمت باستعادة النسخة الاحتياطية، لا بد أن المجلد الرئيسي قد تمت إعادة تسميته إلى "Mitch" من "mitch".

ومع ذلك، لا يزال نظام التشغيل يعتبر مسار المجلد الرئيسي الخاص بي /Users/mitch، كما يظهر من التشغيل echo $HOMEوأيضًا من خلال النظر إلى إعدادات الحساب المتقدمة من تفضيلات النظام.

نظرًا لأن نظام الملفات الذي أستخدمه غير حساس لحالة الأحرف، فكلاهما /Users/mitchيعمل /Users/Mitch.

بعد عدم تمكني من إيجاد حل لمشكلتي، وبعد إضاعة ساعات قليلة عليها، وعدم وجود تثبيت آخر لـ npm أو العقدة، قررت تغيير مسار الدليل الرئيسي من /Users/mitchإلى /Users/Mitch، حيث أن "Mitch" هو الاسم الفعلي للدليل الرئيسي الخاص بي.

لا بد أن هذا كان ذا أهمية بالنسبة لـ nvm، لأن تغيير المسار من تفضيلات النظام أدى إلى حل جميع مشكلاتي.

يعد هذا أمرًا غريبًا لهذا الخطأ، ولكن إذا كنت ترغب في ذلك، فيمكنني على الأقل فتح PR الذي يضيف تحذيرًا بأن "مسار الدليل الرئيسي حساس لحالة الأحرف" أو شيء من هذا القبيل، أو حتى محاولة ضبط الكود نفسه ، وتقديم رمز PR.