← 全部工具

module

热度 65 更新于 开发与构建

Generate the minimal skeleton for a new node.js module/package.

npmauto-collected

安装

npm
npm install -g module

通过 npm 安装。

module [](https://www.npmjs.com/package/module)

Generate the minimal skeleton for a new node.js module/package.

Usage

For example, to create a module in the current working directory:

$ npx module

To create a module in another directory, specify a relative or absolute path:

$ npx module foo

The --system flag can be provided to control whether the module system is ESM (the default if flag not specified) or CommonJS:

$ npx module foo --system esm
$ npx module foo --system cjs

And the --identifier flag can be provided to control whether the module system is identified by file extension (the default if flag not specified), package.json type field, or implicitly from code syntax:

$ npx module foo --system esm --identifier file-ext
$ npx module foo --system cjs --identifier package-type
$ npx module foo --system esm --identifier syntax

To understand these flags better, see Determining module system in the node.js docs.