【问题标题】:Where is the source code of dependencies in node_modules?node_modules中依赖的源码在哪里?
【发布时间】:2019-10-15 05:12:00
【问题描述】:

我是 typescript 和 npm 的初学者,所以我的问题可能看起来很愚蠢。 我在package.json 文件中声明了一些依赖项,并且我已经运行了 npm install 命令。许多依赖项安装到node_modules 目录中。但我认为每个依赖项中都应该有源代码和文档,就像 java 中的那样。但是当我检查node_modules中的依赖时,我只看到了一些包中的类声明:

import { PipeTransform } from '@angular/core';
import { JhiFilterPipe } from './filter.pipe';
export declare class JhiPureFilterPipe extends JhiFilterPipe implements PipeTransform {
    transform(input: Array<any>, filter: string, field: string): any;
}

没有源代码,也没有文档。所以我想知道这些打字稿包中的源代码甚至编译好的js代码在哪里?

在 java 中,当我在 pom 中声明依赖项时,我会看到 API 的源代码及其文档,但在 node_modules 中的包却不是这样。

我做错了吗?

请给我一些提示!

【问题讨论】:

  • 来源。继续查看node_modules 中的from 'whereever';。有些文件可能非常精简,仅用于引入更大的依赖项。查看与您在./filter.pipe 显示的文件相关的文件。那可能会更大。此外,可能不包含任何文档。

标签: node.js typescript npm


【解决方案1】:

所有包都不一样,但是要找到主要代码在哪里,你需要查看package.json文件。在该文件中,您将找到一个 main 键,它将告诉您该包的入口点在哪里(路径相对于 package.json 文件):

{
  "name": "@angular/core",
  "version": "8.0.0-rc.0+354.sha-4809382.with-local-changes",
  "description": "Angular - the core framework",
  "main": "./bundles/core.umd.js"
}

如果您导航到该文件,您将看到该包的入口点源代码。对于您提供的包,the source is here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-07
    • 2012-05-27
    • 2012-12-10
    • 1970-01-01
    • 1970-01-01
    • 2012-04-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多