Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux配置node环境变量 #53

Open
itgoyo opened this issue May 3, 2018 · 0 comments
Open

linux配置node环境变量 #53

itgoyo opened this issue May 3, 2018 · 0 comments

Comments

@itgoyo
Copy link
Owner

itgoyo commented May 3, 2018

特别要注意配置好/etc/profile后,将配置加入/root/.bashrc中;否则,配置的环境变量不会在root账户下生效

方法/步骤

  • 1
    在nodejs官网上下载nodejs源码node-v5.1.0-linux-x64.tar.gz,到/opt目录下;进入/opt目录,输入命令:tar -zxf node-v5.1.0-linux-x64.tar.gz,将文件解压到当前目录

  • 2
    (该步骤可省)输入命令:mv node-v5.1.0-linux-x64.tar.gz node,将文件改名为node

  • 3
    输入命令:vim /etc/profile(如果没有安装vim,可根据提示安装,vim比vi好用多了),在末尾添加以下三行:

export NODE_HOME=/opt/node

export PATH=$PATH:$NODE_HOME/bin

export NODE_PATH=$NODE_HOME/lib/node_modules

之后按Esc键,并输入“:wq!”命令保存配置并推出

  • 4
    在命令行输入:source /etc/profile,然后在命令行输入:node -v,返回版本信息v5.1.0,说明环境变量配置就生效了;但,你会发现进入root账户,改配置并没有生效

  • 5
    在命令行输入:vim /root/.bashrc,并在文件末尾加入一行source etc/profile命令,保存。这样就大功告成了。

  • END
    注意事项
    特别要注意配置好/etc/profile后,将配置加入/root/.bashrc中;否则,配置的环境变量不会在root账户下生效


个人在使用的时候发现配置bash没有效果,原因是linux mint的终端默认启动的是zsh,所以配置要配置在.zshrc文件中

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant