在 Debian 上“配置 JS 运行”通常指 安装 JavaScript 运行环境,最常见的是 Node.js(服务端/命令行 JS)。下面按常见场景说明。
sudo apt update
sudo apt install nodejs npm
检查:
node -v
npm -v
例如安装 Node.js 20:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install --lts
验证:
node -v
新建文件:
nano hello.js
内容:
console.log("Hello Debian");
运行:
node hello.js
Debian 本身不需要配置,JS 由浏览器执行:
sudo apt install chromium
常见组合:
示例:
npm init -y
npm install express
node app.js
node 命令不存在 → 没装或路径不对如果你指的是:
可以告诉我你的具体使用场景,我可以给你更精确配置。