graph

Graph dependencies within workspace.

Usage

โฏ

nx graph

Install nx globally to invoke the command directly using nx, or use npx nx, yarn nx, or pnpm nx.

Examples

Open the project graph of the workspace in the browser:

โฏ

nx graph

Save the project graph into a json file:

โฏ

nx graph --file=output.json

Generate a static website with project graph into an html file, accompanied by an asset folder called static:

โฏ

nx graph --file=output.html

Print the project graph as JSON to the console:

โฏ

nx graph --print

Show the graph where every node is either an ancestor or a descendant of todos-feature-main:

โฏ

nx graph --focus=todos-feature-main

Include project-one and project-two in the project graph:

โฏ

nx graph --include=project-one,project-two

Exclude project-one and project-two from the project graph:

โฏ

nx graph --exclude=project-one,project-two

Show the graph where every node is either an ancestor or a descendant of todos-feature-main, but exclude project-one and project-two:

โฏ

nx graph --focus=todos-feature-main --exclude=project-one,project-two

Watch for changes to project graph and update in-browser:

โฏ

nx graph --watch

Options

OptionTypeDescription
--affectedbooleanHighlight affected projects.
--basestringBase of the current branch (usually main).
--excludestringExclude certain projects from being processed.
--filestringOutput file (e.g. --file=output.json or --file=dep-graph.html).
--filesstringChange the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces.
--focusstringUse to show the project graph for a particular project and every node that is either an ancestor or a descendant.
--groupByFolderbooleanGroup projects by folder in the project graph.
--headstringLatest commit of the current branch (usually HEAD).
--helpbooleanShow help.
--hoststringBind the project graph server to a specific ip address.
--openbooleanOpen the project graph in the browser. (Default: true)
--portnumberBind the project graph server to a specific port.
--printbooleanPrint the project graph to stdout in the terminal.
--targetsstringThe target to show tasks for in the task graph.
--uncommittedbooleanUncommitted changes.
--untrackedbooleanUntracked changes.
--verbosebooleanPrints additional information about the commands (e.g., stack traces).
--versionbooleanShow version number.
--viewprojects, tasksChoose whether to view the projects or task graph. (Default: projects)
--watchbooleanWatch for changes to project graph and update in-browser. (Default: true)