首页 > 编程语言 >Nodejs 安装

Nodejs 安装

时间:2022-09-24 23:23:17浏览次数:81  
标签:node npm Nodejs sudo js https nodesource 安装

目录

Nodejs安装

Node.js 是什么?

Node.js® 是一个基于 Chrome V8 引擎 的 JavaScript 运行时环境。

1. 官网

2. 下载地址

3. 参考文档

4. 安装步骤

4.1 Ubuntu 环境

参考文档:https://github.com/nodesource/distributions/blob/master/README.md#debmanual

4.1.1 移除旧版本 PPA

# add-apt-repository may not be present on some Ubuntu releases:
# sudo apt-get install python-software-properties
sudo add-apt-repository -y -r ppa:chris-lea/node.js
sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list
sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list.save

4.1.2 添加 NodeSource package signing key

KEYRING=/usr/share/keyrings/nodesource.gpg
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | sudo tee "$KEYRING" >/dev/null
# wget can also be used:
# wget --quiet -O - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | sudo tee "$KEYRING" >/dev/null
gpg --no-default-keyring --keyring "$KEYRING" --list-keys

4.1.3 添加期望版本 NodeSource repository

# Replace with the branch of Node.js or io.js you want to install: node_6.x, node_8.x, etc...
VERSION=node_8.x
# Replace with the keyring above, if different
KEYRING=/usr/share/keyrings/nodesource.gpg
# The below command will set this correctly, but if lsb_release isn't available, you can set it manually:
# - For Debian distributions: jessie, sid, etc...
# - For Ubuntu distributions: xenial, bionic, etc...
# - For Debian or Ubuntu derived distributions your best option is to use the codename corresponding to the upstream release your distribution is based off. This is an advanced scenario and unsupported if your distribution is not listed as supported per earlier in this README.
DISTRO="$(lsb_release -s -c)"
echo "deb [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list

4.1.4 更新包列表并且安装 Node.js

sudo apt-get update
sudo apt-get install nodejs

4.2 CentOS7 环境

4.2.1下载安装包

安装包下载地址:https://nodejs.org/zh-cn/download/
image

这里我选择下载 Linux 64位版本
image

4.2.2 安装包上传到服务器

将 node-v16.13.0-linux-x64.tar.xz 上传至服务器。

4.2.3 解压安装包

(1) 将 node-v16.13.0-linux-x64.tar.xz 解压为 node-v16.13.0-linux-x64.tar
解压命令:

xz -d node-v16.13.0-linux-x64.tar.xz

(2) 将 node-v16.13.0-linux-x64.tar 解压
解压命令:

tar -xvf node-v16.13.0-linux-x64.tar

4.2.4 验证

 ## 切换到 安装bin目录下
 cd /opt/nodejs/node-v16.13.0-linux-x64/bin
  ## 查看npm版本
 ./npm -v

image

4.3 windows7 环境

4.3.1下载安装包

安装包下载地址:https://nodejs.org/zh-cn/download/
选择 Windows 安装包 64 位版本。
我这里的版本是 node-v16.13.0-x64.msi

4.3.2 安装

报错,提示 版本不适合windows7:
image

经百度,13.14.0是支持win7 的最后版本是 ,下载地址:https://nodejs.org/download/release/v13.14.0/

image

image

image

image

image

image

4.3.3 验证

打开 CMD 窗口,输入 node -v :
image

安装成功。

CMD 窗口,输入 “npm install npm -g” 命令可安装 npm。

5.使用 npm 安装js 包

https://www.npmjs.com/ 可以搜索应该下载的js包

# 在项目路径下安装 jquery
npm install jquery

image

设置 npm 国内镜像

# 设置 淘宝镜像
npm config set  registry https://registry.npm.taobao.org --global
npm config set  disturl https://npm.taobao.org/dist --global

# 恢复默认镜像 
npm config set  registry https://registry.npmjs.org 

image
没有报错,查看当前镜像:

# 查看当前镜像
npm get  registry 

image

标签:node,npm,Nodejs,sudo,js,https,nodesource,安装
From: https://www.cnblogs.com/lihw-study/p/15527300.html

相关文章

  • 关于 ubuntu 22 desktop 安装 网易云音乐无法启动解决办法
    -报错现象/opt/netease/netease-cloud-music/netease-cloud-music:/opt/netease/netease-cloud-music/libs/libselinux.so.1:noversioninformationavailable(requi......
  • allure-commandline下载、安装、配置(linux或者docker)
    allure-commandline下载下载地址:https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/选择:allure-commandline-2.19.0.zip linux下安装配置u......
  • 环境服务集成工具安装
    一、卸载原来的数据库(MySQL数据库的卸载较为繁琐)1.将和MySQL相关的内容,全部卸载2.找到MySQL的安装目录默认情况下安装在C:\ProgramFiles(x86)和C:\ProgramFiles这两......
  • jenkins在linux下安装(rpm包)
    下载方式一:https://www.jenkins.io/zh/     官网安装参考: 方式二:上面比较慢,我们从清华大学开源镜像站下载安装包:https://mirrors.tuna.tsinghua.edu.......
  • vm-tools安装
    卸载原有sudovmware-uninstall-tools.plsudorm-rf/usr/lib/vmware-toolssudoapt-getautoremoveopen-vm-tools--purge安装sudoapt-getinstallopen-vm-tool......
  • 安装项目模板IdentityServer4.Templates
    打开PowseShell执行以下命令dotnetnew-iIdentityServer4.Templates  ......
  • Jupyter Notebook安装代码提示功能
    默认Jupyter Notebook没有安装代码提示功能,但是我们可以可通过如下命令安装和配置使得Jupyter Notebook具备代码提供功能。(确保Anaconda在环境变量里)1、电脑上搜索“Ana......
  • pycharm下载 安装 详细
    pycharm下载与使用JETBRAINS官网:https://www.jetbrains.com/pycharm/.1.免费版功能太少(community)我们尽量使用收费版(professional)30天试用。选择版本就选......
  • Downie 4 for Mac中文版安装包(最好用的视频下载软件)V4.5.10直装版
    DownieforMac是一款MacOS平台上一款好用的视频下载工具,轻松从数千个不同的网站下载视频。支持youtube等主流网站视频,最大的特点最是支持网站多且可以多点同时下载,只需粘......
  • pycharm的详细安装方法
    pycharm的安装与使用1.该软件分为收费版和免费版免费版功能太少(communit)所以我们尽量使用收费版(professinal)收费版有30天免费试用2.想要免费试用该软件软......