your code touched me
Fork me on GitHub

Linux报“ '/usr/bin' is not included in the PATH environment variable”解决方法

在阿里云的服务器安装nodejs,配置环境变量过程中,出现问题以及解决方法。

1. 以下是node和npm的路径:

2. 设置环境变量

#vi /etc/profile

添加

#set node npm path
NODE_HOME=/home/app/node-v4.0.0-linux-x64/bin
export PATH=$NODE_HOME:$PATH

3. 退出后执行

source /etc/profile

此时 运行node -v没有问题。

但是问题来了,如果以上:$PATH忘了加或者拼写错误,在以后使用ls或者vi等命令会报错

类似于:Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found

**解决方法:**

由于系统找不到原来设置的环境变量,所有需要修改 /etc下的profile文件,

但是此时我们已经不能直接使用vi命令了,其实可以使用

# /usr/bin/vi /etc/profile

修改export PATH=$NODE_HOME:$PATH将其修改正确

此时需要退出当前ssh,再从新登陆,刚才的设置才可生效。

此时测试一下ls命令:

 

本文地址:http://www.cnblogs.com/alvinwei1024/p/4811993.html

 

posted @ 2015-09-16 01:25  AlvinWei  阅读(23732)  评论(0编辑  收藏  举报