# Node.js process 参考

URL: https://caijiao.org/reference/nodejs/process
Source: docs/reference/nodejs/process.md
Description: Node.js process Reference，整理常见语法、ESM 示例、CommonJS 差异、常见错误和相关 Node.js 生态链接。

Node.js process 是 Node.js 核心能力的一部分。ESM 中推荐使用 `node:` 前缀导入；CommonJS 中可使用 `require("node:process")`。

## 语法

```text
process.env.NAME / process.argv
```

## 最小示例

```js
const port = Number(process.env.PORT || 3000);
console.log(process.argv.slice(2), port);
```

## 常见错误

- 混用 ESM 与 CommonJS，导致导入方式不一致。
- 忽略异步错误，未使用 try/catch 或错误事件处理。
- 把示例路径写死到特定系统，导致 Windows 和 Linux 表现不同。

## 相关内容

- [Express 教程](/express/)
- [Fastify 教程](/fastify/)
- [PM2 教程](/pm2/)
- [Docker Reference](/reference/docker/)
