PowerShell 使用技巧(管理员运行)
# 创建配置文件
New-Item -Path $PROFILE -ItemType File -Force
# 编辑配置文件
notepad $PROFILE
# 允许运行脚本
Set-ExecutionPolicy RemoteSigned
一、win 使用 FNM 自动切换 Node.js 版本
初始化 FNM 并启用进入目录时自动切换 Node.js 版本
# 缓存 fnm 是否存在
$useFnm = $null -ne (Get-Command fnm -ErrorAction SilentlyContinue)
fnm env --use-on-cd | Out-String | Invoke-Expression
# 优先检测 .node-version,再 .nvmrc
$versionFile = $null
if (Test-Path ".node-version") {
$versionFile = ".node-version"
} elseif (Test-Path ".nvmrc") {
$versionFile = ".nvmrc"
}
# 如果找到版本文件
if ($versionFile) {
$version = (Get-Content $versionFile -Raw).Trim()
if ($version) {
if ($useFnm) {
fnm use $version
} else {
nvm use $version
}
}
}
目录下新建 .node-version 文件,内容:20.18.3
二、win 内网映射
8000代表映射的本地端口,如果不可用,请尝试80或查看防火墙
ssh -R 80:localhost:8000 serveo.net