当我注销时 Node.js 停止工作

发布于 2024-11-16 17:57:32 字数 912 浏览 2 评论 0原文

我以 root 身份登录到我的 CentOS 5/cPanel 服务器,并输入了以下内容:

cd /usr/local/bin/
git clone --depth 1 http://github.com/joyent/node.git
cd node
git checkout origin/v0.4 # optional.  Note that master is unstable.
export JOBS=2 # optional, sets number of parallel commands.
mkdir ~/local
./configure --prefix=$HOME/local/node
make
make install
echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.profile
source ~/.profile

它似乎工作正常,直到我从服务器注销并重新登录它,因为它尚未安装:

[~]# node test.js
-bash: node: command not found

如果我输入: source ~/.profile 它再次开始工作,直到我注销。

请帮忙。谢谢。

编辑:

这是我的 .bash_profile 的内容,我应该如何更改它?

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

I logged in as root to my CentOS 5/cPanel server and I typed the following:

cd /usr/local/bin/
git clone --depth 1 http://github.com/joyent/node.git
cd node
git checkout origin/v0.4 # optional.  Note that master is unstable.
export JOBS=2 # optional, sets number of parallel commands.
mkdir ~/local
./configure --prefix=$HOME/local/node
make
make install
echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.profile
source ~/.profile

It seems to be working fine until I log out from the server and log back in it's as it wasn't installed:

[~]# node test.js
-bash: node: command not found

If I type: source ~/.profile it starts working again until I log out.

Please help. Thanks.

EDIT:

This is the content of my .bash_profile, how should I change it?

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吃颗糖壮壮胆 2024-11-23 17:57:32

当 bash 作为交互式登录 shell 或带有 --login 选项的非交互式 shell 被调用时,它首先从文件 /etc/profile 中读取并执行命令(如果该文件存在)。读取该文件后,它会按顺序查找 ~/.bash_profile、~/.bash_login 和 ~/.profile,并从存在的第一个读取并执行命令是可读的。启动 shell 时可以使用 --noprofile 选项来禁止此行为。

也许您有一个 .bash_profile 并且正在使用它?

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

Maybe you have a .bash_profile and it's being used instead?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文