@alterior/platform-nodejs

中文文档
3.16.4发布于 2026/07/28MITTypeScriptESM + CJS近 30 天下载 2195

Smoother experience for Alterior on Node.js.

原始使用文档
文档目录3 节
  1. Important note
  2. Usage
  3. What does it do?

@alterior/platform-nodejs

Simplifies idiomatic setup of a Node.js environment for running Alterior applications.

Important note

You must still ensure you enable experimentalDecorators and emitDecoratorMetadata in your tsconfig.json to properly run Alterior applications.

Usage

Within your entry point (usually main.ts):

import '@alterior/platform-nodejs'; // must be first!
import { Application } from '@alterior/runtime';

// other imports here...

Application.bootstrap(MyModule);

Important: Make sure import '@alterior/platform-nodejs'; is the first line in your entrypoint (main.ts).

What does it do?

This does a number of things for you:

  • Loads zone.js as early as possible to ensure all code properly runs within the root Zone.
  • Loads reflect-metadata as early as possible to ensure all subsequently loaded code has Typescript reflection metadata emitted
  • Loads source-map-support/register as early as possible to ensure any stack traces are shown using the available source maps (this avoids seeing compiled JS files in stack traces, instead showing the original source file locations).
  • Loads dotenv/config as early as possible to ensure that any dotenv files are properly accounted for within process.env.
  • Makes fetch() available globally (when not already provided). Does this with globalThis.fetch = require('node-fetch')
  • Makes WebSocket available globally (when not already provided)

版本与发布记录

@alterior/platform-nodejs 共发布 31 个版本,首次发布于 2020/06/08;过去 12 个月发布了 12 个版本。

版本发布日期距今
3.16.4latest2026/07/283 个月前
3.16.32026/07/233 个月前
3.16.22026/05/225 个月前
3.16.12026/05/225 个月前
3.16.02026/05/145 个月前
3.15.02026/02/238 个月前

关于 @alterior/platform-nodejs 的常见问题

@alterior/platform-nodejs 是什么?

Smoother experience for Alterior on Node.js.

如何安装 @alterior/platform-nodejs?

在项目目录运行 npm install @alterior/platform-nodejs,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:zone.js(^0.14.3 || ^0.15.0 || ^0.16.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@alterior/platform-nodejs 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@alterior/platform-nodejs 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@alterior/platform-nodejs 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=10。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@alterior/platform-nodejs 可以商用吗?

@alterior/platform-nodejs 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@alterior/platform-nodejs 的下载量有多少?

根据 npm 官方下载统计,@alterior/platform-nodejs 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,195 次,日均约 73 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@alterior/platform-nodejs 还在维护吗?

最新版本 3.16.4 发布于 2026/07/28(3 个月前);至今共发布 31 个版本,其中过去 12 个月发布了 12 个;首次发布于 2020/06/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。