@depcheck-rs-node/core

中文文档
0.0.32发布于 2022/08/04MITTypeScriptCommonJS近 30 天下载 4864

Depcheck is a tool for analyzing the dependencies in a project to see: how each dependency is used, which dependencies are useless, and which dependencies are missing from package.json. It is a port of original [depcheck](https://github.com/depcheck/dep

原始使用文档
文档目录5 节
  1. Installation
  2. Syntax Support
  3. Usage
  4. API
  5. License

depcheck-rs

Depcheck is a tool for analyzing the dependencies in a project to see: how each dependency is used, which dependencies are useless, and which dependencies are missing from package.json. It is a port of original depcheck. It uses swc for parsing.

Installation

Install with npm:

npm install --save-dev @depcheck-rs-node/core

Install with yarn:

yarn add --dev @depcheck-rs-node/core

Or use rust to install depcheck-rs cli:

cargo install depcheck-rs-cli

Syntax Support

Depcheck not only recognizes the dependencies in JavaScript files, but also supports these syntaxes:

Usage

USAGE:
    depcheck-rs [OPTIONS]

OPTIONS:
    -d, --directory <DIRECTORY>
            The directory argument is the root directory of your project [default: .]

    -h, --help
            Print help information

        --ignore-bin-package
            A flag to indicate if depcheck ignores the packages containing bin entry

        --ignore-path <IGNORE_PATH>
            Path to a file with patterns describing files to ignore

        --ignore-patterns <IGNORE_PATTERNS>
            Comma separated patterns describing files or directories to ignore

        --ignore_matches <IGNORE_MATCHES>
            A comma separated array containing package names to ignore

    -q, --quiet
            Less output per occurrence

        --skip-missing
            A flag to indicate if depcheck skips calculation of missing dependencies

    -v, --verbose
            More output per occurrence

    -V, --version
            Print version information

API


import {depcheck} from "@depcheck-rs-node/core";

const options = {

  ignoreBinPackage: false, // ignore the packages with bin entry

  skipMissing: false, // skip calculation of missing dependencies

  ignorePatterns: [

    // files matching these patterns will be ignored

    'sandbox',

    'dist',

    'bower_components',

  ],

  ignoreMatches: [

    // ignore dependencies that matches these globs

    'grunt-*',

  ],

  ignorePath: '/path/to/your/.depcheckignore',
};

depcheck('/path/to/your/project', options).then((result) => {

  console.log(result.unusedDependencies); // an array containing the unused dependencies

  console.log(result.unusedDevDependencies); // an array containing the unused devDependencies

  console.log(result.missingDependencies); // a lookup containing the dependencies missing in `package.json` and where they are used

  console.log(result.usingDependencies); // a lookup indicating each dependency is used by which files

});

License

MIT License.

版本与发布记录

@depcheck-rs-node/core 共发布 15 个版本,首次发布于 2022/04/12;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.32latest2022/08/044 年前
0.0.282022/05/024 年前
0.0.272022/04/194 年前
0.0.262022/04/194 年前
0.0.242022/04/134 年前
0.0.232022/04/134 年前

关于 @depcheck-rs-node/core 的常见问题

@depcheck-rs-node/core 是什么?

Depcheck is a tool for analyzing the dependencies in a project to see: how each dependency is used, which dependencies are useless, and which dependencies are missing from package.json. It is a port of original [depcheck](https://github.com/depcheck/dep

如何安装 @depcheck-rs-node/core?

在项目目录运行 npm install @depcheck-rs-node/core,或使用 pnpm add / yarn add / bun add。

@depcheck-rs-node/core 支持 TypeScript 吗?

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

@depcheck-rs-node/core 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@depcheck-rs-node/core 需要什么版本的 Node.js?

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

@depcheck-rs-node/core 可以商用吗?

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

@depcheck-rs-node/core 的下载量有多少?

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

@depcheck-rs-node/core 还在维护吗?

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