nvm is not compatible with the npm config “prefix” option:

前端 未结 16 1420
梦毁少年i
梦毁少年i 2020-12-07 06:47

I am trying to run another NodeJS version with nvm but getting this error:

$ nvm use v4.2.4

nvm is not compatible with the npm config \"prefix\         


        
16条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 07:31

    This error can occur when your NVM installation folder path has a Symbolic Link.

    Explanation

    The default installation path of NVM is: $HOME/.nvm but your home folder could be a symbolic link for another drive, like my case.

    Example, my home folder is a Symbolic Link to aother drive:

    /home/myuser -> /bigdrive/myuser

    This cause the prefix problem.

    Solution

    On your startup script (.bashrc or .zshrc or other), change the NVM folder to the direct path.

    Ex: NVM_DIR="/bigdrive/myuser/.nvm".

    .bashrc

    export NVM_DIR="/bigdrive/myuser/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
    

提交回复
热议问题