Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

在Ubuntu上安装nodejs、npm #65

Open
jwenjian opened this issue Jul 17, 2019 · 1 comment
Open

在Ubuntu上安装nodejs、npm #65

jwenjian opened this issue Jul 17, 2019 · 1 comment

Comments

@jwenjian
Copy link
Owner

jwenjian commented Jul 17, 2019

  1. 下载binary包到本地目录

https://nodejs.org/en/download/
目前LTS版本为:node-v10.16.0-linux-x64.tar.xz

假设本地目录为/home/wenjian/Desktop/tools/

  1. 解压
cd /home/wenjian/Desktop/tools
tar -xvf node-v10.16.0-linux-x64.tar.xz
  1. 配置环境变量PATH
vim ~/.bashrc

添加以下内容:

export NODE_HOME=/home/wenjian/Desktop/tools/node-v10.16.0-linux-x64
export PATH=$NODE_HOME/bin:$PATH

重新加载.bashrc

source ~/.bashrc
  1. 配置sudo可执行
sudo ln /home/wenjian/Desktop/tools/node-v10.16.0-linux-x64/bin/node /usr/bin/node -s
sudo ln /home/wenjian/Desktop/tools/node-v10.16.0-linux-x64/bin/npm /usr/bin/npm -s
sudo ln /home/wenjian/Desktop/tools/node-v10.16.0-linux-x64/bin/npx /usr/bin/npx -s
@jwenjian
Copy link
Owner Author

新增了sudo可执行npx命令脚本

关于npx: /~https://github.com/npm/npx

从npm 5.2.0版本开始,安装目录中默认携带了npx命令
image

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

No branches or pull requests

1 participant