[ PROMPT_NODE_25314 ]
runtimes
[ SKILL_DOCUMENTATION ]
# Render 运行时选项
关于 Render 上可用运行时的完整指南,包括每个语言的版本、配置和最佳实践。
## 原生语言运行时
### Node.js (`runtime: node`)
**支持的版本:** 14, 16, 18, 20, 21
**默认版本:** 20
**版本指定:**
在 `package.json` 中指定 Node 版本:
{
"engines": {
"node": "20.x"
}
}
**包管理器:**
- **npm**: 默认,使用 `package-lock.json`
- **Yarn**: 如果存在 `yarn.lock` 则自动检测
- **pnpm**: 如果存在 `pnpm-lock.yaml` 则自动检测
**常用构建命令:**
bash
npm ci # 推荐(更快,可复现)
npm ci && npm run build # 包含构建步骤
yarn install --frozen-lockfile # Yarn 等效命令
pnpm install --frozen-lockfile # pnpm 等效命令
**常用启动命令:**
bash
npm start # 使用 package.json 中的 "start" 脚本
node server.js # 直接执行文件
node dist/main.js # 构建后的输出
**流行框架:**
- Express.js, Fastify, Koa (API)
- Next.js (全栈 React)
- Nest.js (企业级 TypeScript)
- Remix (全栈 React)
- Nuxt.js (全栈 Vue)
**配置示例:**
yaml
type: web
name: node-app
runtime: node
buildCommand: npm ci && npm run build
startCommand: npm start
---
### Python (`runtime: python`)
**支持的版本:** 3.8, 3.9, 3.10, 3.11, 3.12
**默认版本:** 3.11
**版本指定:**
选项 1 - `runtime.txt`:
python-3.11.5
选项 2 - `Pipfile`:
toml
[requires]
python_version = "3.11"
**包管理器:**
- **pip**: 默认,使用 `requirements.txt`
- **Poetry**: 如果存在 `pyproject.toml` 则自动检测
- **Pipenv**: 如果存在 `Pipfile` 则自动检测
**常用构建命令:**
bash
pip install -r requirements.txt
pip install -r requirements.txt && python manage.py collectstatic --no-input
poetry install --no-dev
pipenv install --deploy
**常用启动命令:**
bash
gunicorn app:app # Flask
gunicorn config.wsgi:application # Django
uvicorn main:app --host 0.0.0.0 --port $PORT # FastAPI
celery -A tasks worker # Celery 工作进程
**流行框架:**
- Django (全栈 Web 框架)
- Flask (微框架)
- FastAPI (现代异步 API 框架)
- Celery (任务队列)
**配置示例:**
yaml
type: web
name: python-app
runtime: py