Skip to main content


¥Explore the Project Graph

为了让 Lerna(和 Nx)快速、正确地运行任务,它会创建存储库中所有项目之间的依赖图。直观地探索该图有助于理解 Lerna 为何以某种方式运行,并获得代码架构的高级视图。

¥For Lerna (and Nx) to run tasks quickly and correctly, it creates a graph of the dependencies between all the projects in the repository. Exploring this graph visually can be useful to understand why Lerna is behaving in a certain way and to get a high level view of your code architecture.


¥To launch the project graph visualization run:

nx graph


¥This will open a browser window with an interactive representation of the project graph of your current codebase. Viewing the entire graph can be unmanageable even for smaller repositories, so there are several ways to narrow the focus of the visualization down to the most useful part of the graph at the moment.

  1. 专注于特定项目,然后使用邻近度和按文件夹分组控件来修改该项目周围的图表。

    ¥Focus on a specific project and then use the proximity and group by folder controls to modify the graph around that project.

  2. 使用搜索栏查找名称中包含特定字符串的所有项目。

    ¥Use the search bar to find all projects with names that contain a certain string.

  3. 手动隐藏或显示侧边栏中的项目

    ¥Manually hide or show projects in the sidebar


¥Once the graph is displayed, you can click on an individual dependency link to find out what specific file(s) created that dependency.

JSON 项目图

¥JSON Project Graph


¥If you prefer to analyze the underlying data of the project graph with a script or some other tool, you can run:

nx graph --file=output.json


¥This will give you all the information that is used to create the project graph visualization.