Modifying $PATH variable

后端 未结 3 2103
攒了一身酷
攒了一身酷 2021-02-08 13:44

Trying to install node.js.

Did brew install node

It seems to have worked.

However, received this message upon its completion

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-08 14:26

    Short answer, do this (notice the additional colon I inserted):

    export PATH="/usr/local/share/npm/bin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH"

    The $PATH environment variable is colon separated list of directories to look in if you want to run a command without a fully qualified path (e.g. running npm instead of having to type /usr/local/share/npm/bin/npm).

    You can try this from a terminal before actually saving the change in bash_profile. If everything is good, which -a npm will show you all fully qualified path(s).

    UPDATE

    It is not necessary to modify the $PATH variable in order to use npm. What homebrew install recommends instead is to add the directory where npm-installed binaries are stored to the $PATH variables, so its more convenient to use them from the command line later on.

    Node modules like phantomjs, phonegap, express, etc. provide binaries which after the change are available on the command prompt without having to type the full path.

提交回复
热议问题