Environment Variables

The following environment variables are ones that you can set to change the behavior of Nx in different environments.

PropertyTypeDescription
NX_BASEstringThe default base branch to use when calculating the affected projects. Can be overridden on the command line with --base.
NX_CACHE_DIRECTORYstringThe cache for task outputs is stored in node_modules/.cache/nx by default. Set this variable to use a different directory.
NX_CACHE_PROJECT_GRAPHbooleanIf set to false, disables the project graph cache. Most useful when developing a plugin that modifies the project graph.
NX_DAEMONbooleanIf set to false, disables the Nx daemon process. Disable the daemon to print console.log statements in plugin code you are developing.
NX_HEADstringThe default head branch to use when calculating the affected projects. Can be overridden on the command line with --head.
NX_PERF_LOGGINGbooleanIf set to true, will print debug information useful for for profiling executors and Nx itself
NX_PROFILEstringPrepend NX_PROFILE=profile.json before running targets with Nx to generate a file that be loaded in Chrome dev tools to visualize the performance of Nx across multiple processes.
NX_PROJECT_GRAPH_CACHE_DIRECTORYstringThe project graph cache is stored in node_modules/.cache/nx by default. Set this variable to use a different directory.
NX_PROJECT_GRAPH_MAX_WORKERSnumberThe number of workers to use when calculating the project graph.
NX_RUNNERstringThe name of task runner from the config to use. Can be overridden on the command line with --runner.
NX_SKIP_NX_CACHEbooleanRerun the tasks even when the results are available in the cache
NX_TASKS_RUNNER_DYNAMIC_OUTPUTbooleanIf set to false, will use non-dynamic terminal output strategy (what you see in CI), even when you terminal can support the dynamic version
NX_VERBOSE_LOGGINGbooleanIf set to true, will print debug information useful for troubleshooting
NX_DRY_RUNbooleanIf set to true, will perform a dry run of the generator. No files will be created and no packages will be installed.
NX_INTERACTIVEbooleanIf set to true, will allow Nx to prompt you in the terminal to answer some further questions when running generators.

Nx will set the following environment variables so they can be accessible within the process even outside of executors and generators

PropertyTypeDescription
NX_TASK_TARGET_PROJECTstringSet to the project name of the task being run. Use this to tell which project is being run.
NX_TASK_TARGET_TARGETstringSet to the target name of the task being run. Use this to tell which target of the project is being run.
NX_TASK_TARGET_CONFIGURATIONstringSet to the configuration name of the task being run. Use this to tell which configuration of the target is being run.
NX_DRY_RUNbooleanSet to true during dry runs of generators. Use this to avoid side effects during generators.
NX_INTERACTIVEbooleanSet to false when running generators with --interactive=false. Use this to prevent prompting during generators