安装wsl2

  1. 运行:appwiz.cpl 打开程序和功能
  2. 点击启用或关闭 windows 功能
  3. 勾选这两个选项
  4. 勾选后重启
  5. 重启后,打开微软商店,自动更新wsl,然后安装所需的linux即可。
  6. 如果下载慢,可自行下载,打开链接:
    wsl发行版 json格式
    可以看到下面的内容:
{"Distributions": [{"Name": "Ubuntu","FriendlyName": "Ubuntu","StoreAppId": "9PDXGNCFSCZV","Amd64": true,"Arm64": true,"Amd64PackageUrl": "https://wslstorestorage.blob.core.windows.net/wslblob/Ubuntu2204-220117.appx","Arm64PackageUrl": "https://wslstorestorage.blob.core.windows.net/wslblob/Ubuntu2204-220117_ARM64.appx","PackageFamilyName": "CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc"},{"Name": "Ubuntu-22.04","FriendlyName": "Ubuntu 22.04 LTS","StoreAppId": "9PN20MSR04DW","Amd64": true,"Arm64": true,"Amd64PackageUrl": "https://wslstorestorage.blob.core.windows.net/wslblob/Ubuntu2204LTS-230117.appx","Arm64PackageUrl": "https://wslstorestorage.blob.core.windows.net/wslblob/Ubuntu2204LTS-230117_ARM64.appx","PackageFamilyName": "CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc"},{"Name": "Debian","FriendlyName": "Debian GNU/Linux","StoreAppId": "9MSVKQC78PK6","Amd64": true,"Arm64": true,"Amd64PackageUrl": "https://wsldownload.azureedge.net/TheDebianProject.DebianGNULinux_1.12.2.0_neutral___76v4gfsz19hv4.AppxBundle","Arm64PackageUrl": "https://wsldownload.azureedge.net/TheDebianProject.DebianGNULinux_1.12.2.0_neutral___76v4gfsz19hv4.AppxBundle","PackageFamilyName": "TheDebianProject.DebianGNULinux_76v4gfsz19hv4"},{"Name": "kali-linux","FriendlyName": "Kali Linux Rolling","StoreAppId": "9PKR34TNCV07","Amd64": true,"Arm64": false,"Amd64PackageUrl": "https://wsldownload.azureedge.net/KaliLinux_1.13.1.0.AppxBundle","Arm64PackageUrl": null,"PackageFamilyName": "KaliLinux.54290C8133FEE_ey8k8hqnwqnmg"},{"Name": "SLES-12","FriendlyName": "SUSE Linux Enterprise Server v12","StoreAppId": "9MZ3D1TRP8T1","Amd64": true,"Arm64": false,"Amd64PackageUrl": "https://wsldownload.azureedge.net/SLES-12_v1.appx","Arm64PackageUrl": null,"PackageFamilyName": "46932SUSE.SUSELinuxEnterpriseServer12SP2_022rs5jcyhyac"},{"Name": "SLES-15","FriendlyName": "SUSE Linux Enterprise Server v15","StoreAppId": "9NJFZK00FGKV","Amd64": true,"Arm64": false,"Amd64PackageUrl": null,"Arm64PackageUrl": null,"PackageFamilyName": null},{"Name": "Ubuntu-18.04","FriendlyName": "Ubuntu 18.04 LTS","StoreAppId": "9N9TNGVNDL3Q","Amd64": true,"Arm64": true,"Amd64PackageUrl": "https://wsldownload.azureedge.net/Ubuntu_1804.2019.522.0_x64.appx","Arm64PackageUrl": "https://wsldownload.azureedge.net/Ubuntu_1804.2019.522.0_ARM64.appx","PackageFamilyName": "CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc"},{"Name": "Ubuntu-20.04","FriendlyName": "Ubuntu 20.04 LTS","StoreAppId": "9N6SVWS3RX71","Amd64": true,"Arm64": true,"Amd64PackageUrl": "https://wsldownload.azureedge.net/Ubuntu_2004.2020.424.0_x64.appx","Arm64PackageUrl": "https://wsldownload.azureedge.net/Ubuntu_2004.2020.424.0_ARM64.appx","PackageFamilyName": "CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc"},{"Name": "OracleLinux_8_5","FriendlyName": "Oracle Linux 8.5","StoreAppId": "9P06H18WXBVP","Amd64": true,"Arm64": false,"Amd64PackageUrl": "https://wslstorestorage.blob.core.windows.net/wslblob/OracleLinux8.5_8.5.1.0.Appx","Arm64PackageUrl": null,"PackageFamilyName": "3810OracleAmericaInc.OracleLinux8.5_dm28ctvqnhe9g"},{"Name": "OracleLinux_7_9","FriendlyName": "Oracle Linux 7.9","StoreAppId": "9P7L0QWBSLTK","Amd64": true,"Arm64": false,"Amd64PackageUrl": "https://wslstorestorage.blob.core.windows.net/wslblob/OracleLinux7.9_7.9.1.0.Appx","Arm64PackageUrl": null,"PackageFamilyName": "3810OracleAmericaInc.OracleLinux7.9_dm28ctvqnhe9g"}]
}

下载appx,然后打开文件所在目录,右键 在终端中打开,执行
Add-AppPackage (你的appx文件)
跑完进度条即可。
7. 输入bash,即可进入。
8. 注意事项:defender 不可以禁用, 而且保证 cfg打开。

9. 更多wsl的帮助,见wsl官方文档。

配置Ubuntu

我安装的是Ubuntu-22.04。

  1. 更改源
cd /etc/apt/
# 备份source.list
sudo mv sources.list sources.list.bak
# 修改source.list
sudo vim sources.list
  1. 将下面内容粘贴到文件中
    长江流域建议用中科大源
# 默认注释了源码仓库,如有需要可自行取消注释
deb https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiversedeb https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiversedeb https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiversedeb https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse# 预发布软件源,不建议启用
# deb https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse

北方城市建议用清华源

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-freedeb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

按esc,输入 :wq保存。执行下面的命令进行更新

sudo apt update
sudo apt upgrade

安装一些小工具(可选)

  1. gedit
    我不是用vim的那块材料,老老实实用GUI的编辑器吧。
sudo apt install -y gedit
  1. plocate
sudo apt install -y plocate

不要等命令跑完,跑完要花很长时间。由于wsl2跨文件系统性能很差,因此可以修改配置文件使之不扫描windows文件。

sudo gedit /etc/updatedb.conf

在PRUNEPATHS后添加 /mnt

PRUNE_BIND_MOUNTS="yes"
# PRUNENAMES=".git .bzr .hg .svn"
PRUNEPATHS="/mnt /tmp /var/spool /media /var/lib/os-prober /var/lib/ceph /home/.ecryptfs /var/lib/schroot"
PRUNEFS="NFS afs autofs binfmt_misc ceph cgroup cgroup2 cifs coda configfs curlftpfs debugfs devfs devpts devtmpfs ecryptfs ftpfs fuse.ceph fuse.cryfs fuse.encfs fuse.glusterfs fuse.gvfsd-fuse fuse.mfs fuse.rclone fuse.rozofs fuse.sshfs fusectl fusesmb hugetlbfs iso9660 lustre lustre_lite mfs mqueue ncpfs nfs nfs4 ocfs ocfs2 proc pstore rpc_pipefs securityfs shfs smbfs sysfs tmpfs tracefs udev udf usbfs"

更新数据库

sudo updatedb

查找某个文件

locate [something]
  1. 安装mysql
sudo apt install mysql-server
sudo apt install mysql-client

安装好后,输入 mysql ,我这里会显示错误:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)

执行

cd /var/run
sudo mkdir mysqld
sudo chmod a=rwx mysqld

再次运行,发现还是报错:

ERROR 1045 (28000): Access denied for user 'yourname'@'localhost' (using password: NO)

以root身份运行mysql是正常的。

sudo mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.32-0ubuntu0.22.04.2 (Ubuntu)Copyright (c) 2000, 2023, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

这里引用一下其他人的方法,ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘解决方法以及wsl2(Ubuntu-22.04)配置mysql8.0。
启动mysql

  1. 安装anaconda
    下载链接:anaconda,选择64-Bit (x86) Installer (737 MB)。下载完成后,执行
bash [anaconda-name].sh

更新环境变量

echo 'export PATH="~/anaconda3/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
conda #验证是否安装成功
  1. 修改conda源
    这个文章讲的很详细的:Conda 替换镜像源方法尽头,再也不用到处搜镜像源地址
    注意,打开.condarc文件,在channels:下方如果有 - defaults,一定要删除!否则它还是会去境外下载!
  2. 使用vscode连接到wsl进行开发
    这个文章讲的很详细的:Windows Linux子系统(WSL),vscode+python+jupyter 开发环境搭建

安装node.js、vue.js

  1. 安装nvm
wget https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash

国内访问可能不大行,这里直接贴脚本

#!/usr/bin/env bash{ # this ensures the entire script is downloaded #nvm_has() {type "$1" > /dev/null 2>&1
}nvm_echo() {command printf %s\\n "$*" 2>/dev/null
}if [ -z "${BASH_VERSION}" ] || [ -n "${ZSH_VERSION}" ]; then# shellcheck disable=SC2016nvm_echo >&2 'Error: the install instructions explicitly say to pipe the install script to `bash`; please follow them'exit 1
finvm_grep() {GREP_OPTIONS='' command grep "$@"
}nvm_default_install_dir() {[ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm"
}nvm_install_dir() {if [ -n "$NVM_DIR" ]; thenprintf %s "${NVM_DIR}"elsenvm_default_install_dirfi
}nvm_latest_version() {nvm_echo "v0.39.3"
}nvm_profile_is_bash_or_zsh() {local TEST_PROFILETEST_PROFILE="${1-}"case "${TEST_PROFILE-}" in*"/.bashrc" | *"/.bash_profile" | *"/.zshrc" | *"/.zprofile")return;;*)return 1;;esac
}#
# Outputs the location to NVM depending on:
# * The availability of $NVM_SOURCE
# * The method used ("script" or "git" in the script, defaults to "git")
# NVM_SOURCE always takes precedence unless the method is "script-nvm-exec"
#
nvm_source() {local NVM_GITHUB_REPONVM_GITHUB_REPO="${NVM_INSTALL_GITHUB_REPO:-nvm-sh/nvm}"local NVM_VERSIONNVM_VERSION="${NVM_INSTALL_VERSION:-$(nvm_latest_version)}"local NVM_METHODNVM_METHOD="$1"local NVM_SOURCE_URLNVM_SOURCE_URL="$NVM_SOURCE"if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; thenNVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm-exec"elif [ "_$NVM_METHOD" = "_script-nvm-bash-completion" ]; thenNVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/bash_completion"elif [ -z "$NVM_SOURCE_URL" ]; thenif [ "_$NVM_METHOD" = "_script" ]; thenNVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm.sh"elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; thenNVM_SOURCE_URL="https://github.com/${NVM_GITHUB_REPO}.git"elsenvm_echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"return 1fifinvm_echo "$NVM_SOURCE_URL"
}#
# Node.js version to install
#
nvm_node_version() {nvm_echo "$NODE_VERSION"
}nvm_download() {if nvm_has "curl"; thencurl --fail --compressed -q "$@"elif nvm_has "wget"; then# Emulate curl with wgetARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \-e 's/--compressed //' \-e 's/--fail //' \-e 's/-L //' \-e 's/-I /--server-response /' \-e 's/-s /-q /' \-e 's/-sS /-nv /' \-e 's/-o /-O /' \-e 's/-C - /-c /')# shellcheck disable=SC2086eval wget $ARGSfi
}install_nvm_from_git() {local INSTALL_DIRINSTALL_DIR="$(nvm_install_dir)"local NVM_VERSIONNVM_VERSION="${NVM_INSTALL_VERSION:-$(nvm_latest_version)}"if [ -n "${NVM_INSTALL_VERSION:-}" ]; then# Check if version is an existing refif command git ls-remote "$(nvm_source "git")" "$NVM_VERSION" | nvm_grep -q "$NVM_VERSION" ; then:# Check if version is an existing changesetelif ! nvm_download -o /dev/null "$(nvm_source "script-nvm-exec")"; thennvm_echo >&2 "Failed to find '$NVM_VERSION' version."exit 1fifilocal fetch_errorif [ -d "$INSTALL_DIR/.git" ]; then# Updating reponvm_echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"command printf '\r=> 'fetch_error="Failed to update nvm with $NVM_VERSION, run 'git fetch' in $INSTALL_DIR yourself."elsefetch_error="Failed to fetch origin with $NVM_VERSION. Please report this!"nvm_echo "=> Downloading nvm from git to '$INSTALL_DIR'"command printf '\r=> 'mkdir -p "${INSTALL_DIR}"if [ "$(ls -A "${INSTALL_DIR}")" ]; then# Initializing repocommand git init "${INSTALL_DIR}" || {nvm_echo >&2 'Failed to initialize nvm repo. Please report this!'exit 2}command git --git-dir="${INSTALL_DIR}/.git" remote add origin "$(nvm_source)" 2> /dev/null \|| command git --git-dir="${INSTALL_DIR}/.git" remote set-url origin "$(nvm_source)" || {nvm_echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'exit 2}else# Cloning repocommand git clone "$(nvm_source)" --depth=1 "${INSTALL_DIR}" || {nvm_echo >&2 'Failed to clone nvm repo. Please report this!'exit 2}fifi# Try to fetch tagif command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin tag "$NVM_VERSION" --depth=1 2>/dev/null; then:# Fetch given versionelif ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin "$NVM_VERSION" --depth=1; thennvm_echo >&2 "$fetch_error"exit 1ficommand git -c advice.detachedHead=false --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout -f --quiet FETCH_HEAD || {nvm_echo >&2 "Failed to checkout the given version $NVM_VERSION. Please report this!"exit 2}if [ -n "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; thenif command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; thencommand git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1elsenvm_echo >&2 "Your version of git is out of date. Please update it!"command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch -D master >/dev/null 2>&1fifinvm_echo "=> Compressing and cleaning up git repository"if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" reflog expire --expire=now --all; thennvm_echo >&2 "Your version of git is out of date. Please update it!"fiif ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" gc --auto --aggressive --prune=now ; thennvm_echo >&2 "Your version of git is out of date. Please update it!"fireturn
}#
# Automatically install Node.js
#
nvm_install_node() {local NODE_VERSION_LOCALNODE_VERSION_LOCAL="$(nvm_node_version)"if [ -z "$NODE_VERSION_LOCAL" ]; thenreturn 0finvm_echo "=> Installing Node.js version $NODE_VERSION_LOCAL"nvm install "$NODE_VERSION_LOCAL"local CURRENT_NVM_NODECURRENT_NVM_NODE="$(nvm_version current)"if [ "$(nvm_version "$NODE_VERSION_LOCAL")" == "$CURRENT_NVM_NODE" ]; thennvm_echo "=> Node.js version $NODE_VERSION_LOCAL has been successfully installed"elsenvm_echo >&2 "Failed to install Node.js $NODE_VERSION_LOCAL"fi
}install_nvm_as_script() {local INSTALL_DIRINSTALL_DIR="$(nvm_install_dir)"local NVM_SOURCE_LOCALNVM_SOURCE_LOCAL="$(nvm_source script)"local NVM_EXEC_SOURCENVM_EXEC_SOURCE="$(nvm_source script-nvm-exec)"local NVM_BASH_COMPLETION_SOURCENVM_BASH_COMPLETION_SOURCE="$(nvm_source script-nvm-bash-completion)"# Downloading to $INSTALL_DIRmkdir -p "$INSTALL_DIR"if [ -f "$INSTALL_DIR/nvm.sh" ]; thennvm_echo "=> nvm is already installed in $INSTALL_DIR, trying to update the script"elsenvm_echo "=> Downloading nvm as script to '$INSTALL_DIR'"finvm_download -s "$NVM_SOURCE_LOCAL" -o "$INSTALL_DIR/nvm.sh" || {nvm_echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'"return 1} &nvm_download -s "$NVM_EXEC_SOURCE" -o "$INSTALL_DIR/nvm-exec" || {nvm_echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"return 2} &nvm_download -s "$NVM_BASH_COMPLETION_SOURCE" -o "$INSTALL_DIR/bash_completion" || {nvm_echo >&2 "Failed to download '$NVM_BASH_COMPLETION_SOURCE'"return 2} &for job in $(jobs -p | command sort)dowait "$job" || return $?donechmod a+x "$INSTALL_DIR/nvm-exec" || {nvm_echo >&2 "Failed to mark '$INSTALL_DIR/nvm-exec' as executable"return 3}
}nvm_try_profile() {if [ -z "${1-}" ] || [ ! -f "${1}" ]; thenreturn 1finvm_echo "${1}"
}#
# Detect profile file if not specified as environment variable
# (eg: PROFILE=~/.myprofile)
# The echo'ed path is guaranteed to be an existing file
# Otherwise, an empty string is returned
#
nvm_detect_profile() {if [ "${PROFILE-}" = '/dev/null' ]; then# the user has specifically requested NOT to have nvm touch their profilereturnfiif [ -n "${PROFILE}" ] && [ -f "${PROFILE}" ]; thennvm_echo "${PROFILE}"returnfilocal DETECTED_PROFILEDETECTED_PROFILE=''if [ "${SHELL#*bash}" != "$SHELL" ]; thenif [ -f "$HOME/.bashrc" ]; thenDETECTED_PROFILE="$HOME/.bashrc"elif [ -f "$HOME/.bash_profile" ]; thenDETECTED_PROFILE="$HOME/.bash_profile"fielif [ "${SHELL#*zsh}" != "$SHELL" ]; thenif [ -f "$HOME/.zshrc" ]; thenDETECTED_PROFILE="$HOME/.zshrc"elif [ -f "$HOME/.zprofile" ]; thenDETECTED_PROFILE="$HOME/.zprofile"fifiif [ -z "$DETECTED_PROFILE" ]; thenfor EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zprofile" ".zshrc"doif DETECTED_PROFILE="$(nvm_try_profile "${HOME}/${EACH_PROFILE}")"; thenbreakfidonefiif [ -n "$DETECTED_PROFILE" ]; thennvm_echo "$DETECTED_PROFILE"fi
}#
# Check whether the user has any globally-installed npm modules in their system
# Node, and warn them if so.
#
nvm_check_global_modules() {local NPM_COMMANDNPM_COMMAND="$(command -v npm 2>/dev/null)" || return 0[ -n "${NVM_DIR}" ] && [ -z "${NPM_COMMAND%%"$NVM_DIR"/*}" ] && return 0local NPM_VERSIONNPM_VERSION="$(npm --version)"NPM_VERSION="${NPM_VERSION:--1}"[ "${NPM_VERSION%%[!-0-9]*}" -gt 0 ] || return 0local NPM_GLOBAL_MODULESNPM_GLOBAL_MODULES="$(npm list -g --depth=0 |command sed -e '/ npm@/d' -e '/ (empty)$/d')"local MODULE_COUNTMODULE_COUNT="$(command printf %s\\n "$NPM_GLOBAL_MODULES" |command sed -ne '1!p' |                     # Remove the first linewc -l | command tr -d ' '                   # Count entries)"if [ "${MODULE_COUNT}" != '0' ]; then# shellcheck disable=SC2016nvm_echo '=> You currently have modules installed globally with `npm`. These will no'# shellcheck disable=SC2016nvm_echo '=> longer be linked to the active version of Node when you install a new node'# shellcheck disable=SC2016nvm_echo '=> with `nvm`; and they may (depending on how you construct your `$PATH`)'# shellcheck disable=SC2016nvm_echo '=> override the binaries of modules installed with `nvm`:'nvm_echocommand printf %s\\n "$NPM_GLOBAL_MODULES"nvm_echo '=> If you wish to uninstall them at a later point (or re-install them under your'# shellcheck disable=SC2016nvm_echo '=> `nvm` Nodes), you can remove them from the system Node as follows:'nvm_echonvm_echo '     $ nvm use system'nvm_echo '     $ npm uninstall -g a_module'nvm_echofi
}nvm_do_install() {if [ -n "${NVM_DIR-}" ] && ! [ -d "${NVM_DIR}" ]; thenif [ -e "${NVM_DIR}" ]; thennvm_echo >&2 "File \"${NVM_DIR}\" has the same name as installation directory."exit 1fiif [ "${NVM_DIR}" = "$(nvm_default_install_dir)" ]; thenmkdir "${NVM_DIR}"elsenvm_echo >&2 "You have \$NVM_DIR set to \"${NVM_DIR}\", but that directory does not exist. Check your profile files and environment."exit 1fifi# Disable the optional which check, https://www.shellcheck.net/wiki/SC2230# shellcheck disable=SC2230if nvm_has xcode-select && [ "$(xcode-select -p >/dev/null 2>/dev/null ; echo $?)" = '2' ] && [ "$(which git)" = '/usr/bin/git' ] && [ "$(which curl)" = '/usr/bin/curl' ]; thennvm_echo >&2 'You may be on a Mac, and need to install the Xcode Command Line Developer Tools.'# shellcheck disable=SC2016nvm_echo >&2 'If so, run `xcode-select --install` and try again. If not, please report this!'exit 1fiif [ -z "${METHOD}" ]; then# Autodetect install methodif nvm_has git; theninstall_nvm_from_gitelif nvm_has curl || nvm_has wget; theninstall_nvm_as_scriptelsenvm_echo >&2 'You need git, curl, or wget to install nvm'exit 1fielif [ "${METHOD}" = 'git' ]; thenif ! nvm_has git; thennvm_echo >&2 "You need git to install nvm"exit 1fiinstall_nvm_from_gitelif [ "${METHOD}" = 'script' ]; thenif ! nvm_has curl && ! nvm_has wget; thennvm_echo >&2 "You need curl or wget to install nvm"exit 1fiinstall_nvm_as_scriptelsenvm_echo >&2 "The environment variable \$METHOD is set to \"${METHOD}\", which is not recognized as a valid installation method."exit 1finvm_echolocal NVM_PROFILENVM_PROFILE="$(nvm_detect_profile)"local PROFILE_INSTALL_DIRPROFILE_INSTALL_DIR="$(nvm_install_dir | command sed "s:^$HOME:\$HOME:")"SOURCE_STR="\\nexport NVM_DIR=\"${PROFILE_INSTALL_DIR}\"\\n[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\"  # This loads nvm\\n"# shellcheck disable=SC2016COMPLETION_STR='[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion\n'BASH_OR_ZSH=falseif [ -z "${NVM_PROFILE-}" ] ; thenlocal TRIED_PROFILEif [ -n "${PROFILE}" ]; thenTRIED_PROFILE="${NVM_PROFILE} (as defined in \$PROFILE), "finvm_echo "=> Profile not found. Tried ${TRIED_PROFILE-}~/.bashrc, ~/.bash_profile, ~/.zprofile, ~/.zshrc, and ~/.profile."nvm_echo "=> Create one of them and run this script again"nvm_echo "   OR"nvm_echo "=> Append the following lines to the correct file yourself:"command printf "${SOURCE_STR}"nvm_echoelseif nvm_profile_is_bash_or_zsh "${NVM_PROFILE-}"; thenBASH_OR_ZSH=truefiif ! command grep -qc '/nvm.sh' "$NVM_PROFILE"; thennvm_echo "=> Appending nvm source string to $NVM_PROFILE"command printf "${SOURCE_STR}" >> "$NVM_PROFILE"elsenvm_echo "=> nvm source string already in ${NVM_PROFILE}"fi# shellcheck disable=SC2016if ${BASH_OR_ZSH} && ! command grep -qc '$NVM_DIR/bash_completion' "$NVM_PROFILE"; thennvm_echo "=> Appending bash_completion source string to $NVM_PROFILE"command printf "$COMPLETION_STR" >> "$NVM_PROFILE"elsenvm_echo "=> bash_completion source string already in ${NVM_PROFILE}"fifiif ${BASH_OR_ZSH} && [ -z "${NVM_PROFILE-}" ] ; thennvm_echo "=> Please also append the following lines to the if you are using bash/zsh shell:"command printf "${COMPLETION_STR}"fi# Source nvm# shellcheck source=/dev/null\. "$(nvm_install_dir)/nvm.sh"nvm_check_global_modulesnvm_install_nodenvm_resetnvm_echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:"command printf "${SOURCE_STR}"if ${BASH_OR_ZSH} ; thencommand printf "${COMPLETION_STR}"fi
}#
# Unsets the various functions defined
# during the execution of the install script
#
nvm_reset() {unset -f nvm_has nvm_install_dir nvm_latest_version nvm_profile_is_bash_or_zsh \nvm_source nvm_node_version nvm_download install_nvm_from_git nvm_install_node \install_nvm_as_script nvm_try_profile nvm_detect_profile nvm_check_global_modules \nvm_do_install nvm_reset nvm_default_install_dir nvm_grep
}[ "_$NVM_ENV" = "_testing" ] || nvm_do_install} # this ensures the entire script is downloaded #
  1. 关闭该终端,重新开启一个新终端。输入nvm,应该可以看到:

Node Version Manager (v0.39.3)Note: <version> refers to any version-like string nvm understands. This includes:- full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)- default (built-in) aliases: node, stable, unstable, iojs, system- custom aliases you define with `nvm alias foo`

篇幅有限,就不全贴出来了。
3. 安装最新的lts版本

nvm install --lts
  1. 安装好后,输入node,可以看到:
Welcome to Node.js v18.15.0.
Type ".help" for more information.
>
  1. 安装nrm
npm install nrm -g
  1. 显示可用的镜像站
nrm ls

显示

  npm ---------- https://registry.npmjs.org/yarn --------- https://registry.yarnpkg.com/tencent ------ https://mirrors.cloud.tencent.com/npm/cnpm --------- https://r.cnpmjs.org/taobao ------- https://registry.npmmirror.com/npmMirror ---- https://skimdb.npmjs.com/registry/

切换为淘宝:

nrm use taobao

显示:

   Registry has been set to: https://registry.npmmirror.com/
  1. 创建Vue3项目
    在即将放项目的目录下,执行
npm init vue@latest

之后按需求回答一些问题即可。

注意事项

1、在windows 通过IDEA开发,wsl2中一些文件最好不要使用软连接,否则IDEA不认

【wsl2】从头开始配置相关推荐

  1. 新买的服务器怎么安装Linux,买了新服务器,如何从头开始配置?Ubuntu系统安装+新建用户名+挂...

    买了新服务器,如何从头开始配置?Ubuntu系统安装+新建用户名+挂 买了新服务器,如何从头开始配置?Ubuntu系统安装+新建用户名+挂载硬盘+nvidia安装+cuda安装+cudnn安装+ana ...

  2. win10 WSL2 使用Ubuntu配置与安装教程

    写在最前面:最终还是选择了远程访问阿里云服务器的方式实现一台电脑同时使用win10+ubuntu双系统.本人不才,怎么操作都无法使win10 WSL(2) 满足systemd与桌面同时work.只能放 ...

  3. window子系统 wsl2 ubuntu子系统配置代理

    原理: 由于 ubuntu 子系统是一个虚拟机, 虚拟机安装下载包缓慢,而我们需要虚拟机使用到外部window电脑的代理网络使子系统能快速安装搭建服务. 方法: ubuntu 子系统需要获取到wind ...

  4. 从头安装配置manjaro操作系统

    1. 启动盘制作 ventoy:非常好用的一个多系统启动盘制作软件! 第一步打开ventoy,点击安装即可. 第二步将下载好的ios镜像文件拷贝到u盘中. 避坑:如果使用普通的u盘录制软件烧录,系统识 ...

  5. Windows中WSL2 配置运行GNOME桌面版 Ubuntu

    本文将一步一步教你如何在WSL2 中 Ubuntu 配置运行 GNOME 桌面环境. 注意:如果您想要终极 Linux 桌面体验,我强烈建议您安装 Linux 作为你的主要操作系统. 网上的很多教程都 ...

  6. Windows上最全wsl2使用配置,包含基础配置、高级配置、开发工具、机器学习环境配置、机器人与自动驾驶环境配置(如Ros及百度的无人驾驶系统apollo)、服务器及Web开发环境配置等等

    Windows上最全wsl2使用配置,包含基础配置.高级配置.开发工具.机器学习环境配置.机器人与自动驾驶环境配置(如Ros及百度的无人驾驶系统apollo).服务器及Web开发环境配置等等. 文章比 ...

  7. 超详细配置教程,搭建 Windows 深度学习环境

    点击上方"视学算法",选择加"星标"或"置顶" 重磅干货,第一时间送达 选自 | towardsdatascience 作者 | Ahina ...

  8. 用Windows电脑训练深度学习模型?超详细配置教程来了

    选自towardsdatascience 作者:Ahinand 机器之心编译 编辑:Panda 虽然大多数深度学习模型都是在 Linux 系统上训练的,但 Windows 也是一个非常重要的系统,也可 ...

  9. tensorflow linux多卡训练_用Windows电脑训练深度学习模型?超详细配置教程来了

    公众号关注 "DL-CVer" 设为 "星标",DLCV消息即可送达! 转自 机器之心 虽然大多数深度学习模型都是在 Linux 系统上训练的,但 Window ...

最新文章

  1. 深浅拷贝、函数、内置函数、文件处理、三元运算、递归
  2. “北航Clubs” Beta版本开发目标
  3. 【学习笔记】利用Excel实现简易版大屏
  4. Android Git 常用命令和规范
  5. masm5安装教程_汇编语言程序环境搭建masm+debug64位 win10/7
  6. 干货 | 深度学习的可解释性研究(一):让模型「说人话」
  7. 博士哭诉自己入职深大7年,月薪不足3000开不起网课,望学校补助
  8. Intel 64/x86_64/IA-32/x86处理器 - 指令格式(9) - 64位指令格式(通用格式)
  9. 贴片晶振脚位_贴片晶振的焊接方法和注意事项
  10. BZOJ 2763[JLOI2011]飞行路线 - 最短路
  11. Oracle 开窗函数--转
  12. 非递归遍历二叉树-前序中序
  13. SDN/NFV在演进中探寻路径
  14. php基础案例例子,PHP基础案例教程
  15. 惠普打印机换硒鼓图解_hp硒鼓怎么安装 hp硒鼓安装方法这图文教程】
  16. 关于希捷维修日志中 FAIL Servo Op=0100 Resp=0003 错误信息的解读
  17. VRRP——VRRP讲解
  18. 镜像翻转_98年“后浪”科学家,首次挑战图片翻转不变性假设,一作拿下CVPR最佳论文提名...
  19. 如何将flac音频格式转换mp3格式呢
  20. 微软培植托管增值产业链 SaaS落地面临挑战

热门文章

  1. go 字符转ASCII 字符转成数字
  2. java去掉转义字符,双引号,全角空格
  3. 服务器虚拟化解锁方案,RX 5700乐成刷入RX 5700 XT BIOS:频率、功耗双双解锁
  4. Vue如何使用ECharts
  5. win7系统怎么删除电脑运行记录?
  6. 浅聊关于vue.js
  7. 记录——kubeadm集群node节点加入
  8. 1th matlab与遗传算法工具箱
  9. mysql刷新当前数据库_sqlyog刷新数据库
  10. AI作诗:诗三百·人工智能诗歌写作平台