Install Nx in a Non-Javascript Repo

Nx can manage its own installation without requiring a package.json file or a node_modules folder. This type of installation is useful for repositories that may not contain any JavaScript or TypeScript (e.g. .Net or Java based workspaces that want to leverage Nx features). In this setup, the Nx CLI is all contained within a .nx folder.

Usage

You can install Nx in the .nx/installation directory by running nx init in a directory without package.json, and picking to install Nx in the current directory.

When Nx is installed in .nx, you can run Nx via a global Nx installation or the nx and nx.bat scripts that were created. In either case, the wrapper (.nx/nxw.js) will be invoked and ensure that the current workspace is up to date prior to invoking Nx.

โฏ

> nx build my-project

โฏ

> nx generate application

โฏ

> nx graph

Available since Nx v15.8.7

Support for --use-dot-nx-installation was added in Nx v15.8.7. To ensure that it is available, specify the version of nx when running your command so that npx doesn't accept an older version that is in the cache. (e.g. npx nx@latest init)

Installing Plugins

When Nx is managing its own installation, you can install plugins with nx add {pluginName}. This will install the plugin in the .nx folder and add it to the nx.json file. To manually install a plugin, you can add the plugin to nx.json as shown below:

nx.json
1{ 2 "plugins": [ 3 { 4 "plugin": "{pluginName}", 5 "version": "1.0.0" 6 } 7 ] 8} 9

The next time you run Nx, the plugin will be installed and available for use.