docs(core): move global & nx wrapper to installation page

This commit is contained in:
Juri 2023-10-18 22:09:39 +02:00 committed by Juri Strumpflohner
parent 96b8bdba60
commit 15f558d253
7 changed files with 6 additions and 277 deletions

View File

@ -983,22 +983,6 @@
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Nx and the Nx Wrapper",
"path": "/concepts/more-concepts/nx-and-the-wrapper",
"id": "nx-and-the-wrapper",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Managing your Global Nx Installation",
"path": "/concepts/more-concepts/global-nx",
"id": "global-nx",
"isExternal": false,
"children": [],
"disableCollapsible": false
}
],
"disableCollapsible": false
@ -1260,22 +1244,6 @@
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Nx and the Nx Wrapper",
"path": "/concepts/more-concepts/nx-and-the-wrapper",
"id": "nx-and-the-wrapper",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Managing your Global Nx Installation",
"path": "/concepts/more-concepts/global-nx",
"id": "global-nx",
"isExternal": false,
"children": [],
"disableCollapsible": false
}
],
"disableCollapsible": false
@ -1416,22 +1384,6 @@
"children": [],
"disableCollapsible": false
},
{
"name": "Nx and the Nx Wrapper",
"path": "/concepts/more-concepts/nx-and-the-wrapper",
"id": "nx-and-the-wrapper",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Managing your Global Nx Installation",
"path": "/concepts/more-concepts/global-nx",
"id": "global-nx",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Recipes",
"path": "/recipes",

View File

@ -1225,26 +1225,6 @@
"isExternal": false,
"path": "/concepts/more-concepts/how-project-graph-is-built",
"tags": ["explore-graph"]
},
{
"id": "nx-and-the-wrapper",
"name": "Nx and the Nx Wrapper",
"description": "",
"file": "shared/guides/nx-and-the-wrapper",
"itemList": [],
"isExternal": false,
"path": "/concepts/more-concepts/nx-and-the-wrapper",
"tags": []
},
{
"id": "global-nx",
"name": "Managing your Global Nx Installation",
"description": "",
"file": "shared/guides/global-nx",
"itemList": [],
"isExternal": false,
"path": "/concepts/more-concepts/global-nx",
"tags": []
}
],
"isExternal": false,
@ -1572,26 +1552,6 @@
"isExternal": false,
"path": "/concepts/more-concepts/how-project-graph-is-built",
"tags": ["explore-graph"]
},
{
"id": "nx-and-the-wrapper",
"name": "Nx and the Nx Wrapper",
"description": "",
"file": "shared/guides/nx-and-the-wrapper",
"itemList": [],
"isExternal": false,
"path": "/concepts/more-concepts/nx-and-the-wrapper",
"tags": []
},
{
"id": "global-nx",
"name": "Managing your Global Nx Installation",
"description": "",
"file": "shared/guides/global-nx",
"itemList": [],
"isExternal": false,
"path": "/concepts/more-concepts/global-nx",
"tags": []
}
],
"isExternal": false,
@ -1768,26 +1728,6 @@
"path": "/concepts/more-concepts/how-project-graph-is-built",
"tags": ["explore-graph"]
},
"/concepts/more-concepts/nx-and-the-wrapper": {
"id": "nx-and-the-wrapper",
"name": "Nx and the Nx Wrapper",
"description": "",
"file": "shared/guides/nx-and-the-wrapper",
"itemList": [],
"isExternal": false,
"path": "/concepts/more-concepts/nx-and-the-wrapper",
"tags": []
},
"/concepts/more-concepts/global-nx": {
"id": "global-nx",
"name": "Managing your Global Nx Installation",
"description": "",
"file": "shared/guides/global-nx",
"itemList": [],
"isExternal": false,
"path": "/concepts/more-concepts/global-nx",
"tags": []
},
"/recipes": {
"id": "recipes",
"name": "Recipes",

View File

@ -434,16 +434,6 @@
"id": "how-project-graph-is-built",
"tags": ["explore-graph"],
"file": "shared/concepts/how-project-graph-is-built"
},
{
"name": "Nx and the Nx Wrapper",
"id": "nx-and-the-wrapper",
"file": "shared/guides/nx-and-the-wrapper"
},
{
"name": "Managing your Global Nx Installation",
"id": "global-nx",
"file": "shared/guides/global-nx"
}
]
}

View File

@ -1,108 +0,0 @@
# Managing your Global Nx Installation
Nx can be ran in a total of 3 ways:
- Through your package manager (e.g. `npx nx`, `yarn nx`, or `pnpm exec nx`)
- Through [./nx or ./nx.bat](/concepts/more-concepts/nx-and-the-wrapper)
- Through a global Nx installation (e.g. `nx`)
With a global Nx installation, Nx looks for the local copy of Nx in your repo and hands off the process execution to it. This means that whichever version of Nx is installed locally in your repo is still the version of Nx that runs your code. For the most part, this can eliminate any issues that may arise from the global install being outdated.
## Installing Nx Globally
Depending on your package manager of choice, you can install Nx with the following commands:
{% tabs %}
{% tab label="npm" %}
```shell
npm install --global nx@latest
```
{% /tab %}
{% tab label="yarn" %}
```shell
yarn global add nx@latest
```
{% /tab %}
{% tab label="pnpm" %}
```shell
pnpm install --global nx@latest
```
{% /tab %}
{% /tabs %}
## Updating your global Nx installation
There are some cases where an issue could arise when using an outdated global installation of Nx. If the structure of your Nx workspace no longer matches up with what the globally installed copy of Nx expects, it may fail to hand off to your local installation properly and instead error. This commonly results in errors such as:
- Could not find Nx modules in this workspace.
- The current directory isn't part of an Nx workspace.
If you find yourself in this position, you will need to update your global install of Nx.
In most cases, you can update a globally installed npm package by rerunning the command you used to install it, as described [above](#installing-nx-globally)
If you cannot remember which package manager you installed Nx globally with or are still encountering issues, you can locate other installs of Nx with these commands:
{% tabs %}
{% tab label="npm" %}
```shell
npm list --global nx
```
{% /tab %}
{% tab label="yarn" %}
```shell
yarn global list nx
```
{% /tab %}
{% tab label="pnpm" %}
```shell
pnpm list --global nx
```
{% /tab %}
{% /tabs %}
{% callout type="note" title="Older Global Installations" %}
In prior versions, Nx could be installed globally via `@nrwl/cli` or `@nrwl/tao`. If you are seeing these warnings but cannot find other global installations of Nx via the above commands, you should look for these packages as well. In general, you should remove these and install the latest version of `nx` instead.
{% /callout %}
You can then remove the extra global installations by running the following commands for the duplicate installations:
{% tabs %}
{% tab label="npm" %}
```shell
npm rm --global nx @nrwl/cli @nrwl/tao
```
{% /tab %}
{% tab label="yarn" %}
```shell
yarn global remove nx @nrwl/cli @nrwl/tao
```
{% /tab %}
{% tab label="pnpm" %}
```shell
pnpm rm --global nx @nrwl/cli @nrwl/tao
```
{% /tab %}
{% /tabs %}
Finally, to complete your global installation update, simply reinstall it as described [above](#installing-nx-globally).

View File

@ -1,47 +0,0 @@
# `.nx` and the Nx Wrapper
Nx is able to manage its own installation via the `.nx` directory. This installation is described within [nx.json](/reference/nx-json#installation).
By allowing Nx to manage its installation, a given repository is no longer required to contain a package.json or node_modules in its root. This is useful for repositories which may not contain any javascript or typescript. Additionally, since the Nx installation is managed inside `.nx`, it is easier to separate out from your other dependencies.
## 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.
{% tabs %}
{% tab label="Global Install" %}
```shell
> nx build my-project
> nx generate application
> nx graph
```
{% /tab %}
{% tab label="nx shell script" %}
```shell
> ./nx build my-project
> ./nx generate application
> ./nx graph
```
{% /tab %}
{% tab label="nx.bat" %}
```shell
> ./nx.bat build my-project
> ./nx.bat generate application
> ./nx.bat graph
```
{% /tab %}
{% /tabs %}
{% callout type="note" title="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`)
{% /callout %}

View File

@ -74,8 +74,6 @@
- [Grouping Libraries](/concepts/more-concepts/grouping-libraries)
- [Buildable and Publishable Libraries](/concepts/more-concepts/buildable-and-publishable-libraries)
- [How the Project Graph is Built](/concepts/more-concepts/how-project-graph-is-built)
- [Nx and the Nx Wrapper](/concepts/more-concepts/nx-and-the-wrapper)
- [Managing your Global Nx Installation](/concepts/more-concepts/global-nx)
- [Recipes](/recipes)
- [Tasks & Caching](/recipes/running-tasks)
- [Fine-tuning Caching with Inputs](/recipes/running-tasks/customizing-inputs)

View File

@ -887,7 +887,7 @@ const latestRecipesRefactoring = {
'/reference/commands': '/packages/nx',
};
const coreFeatureRefactoring = {
const coreFeatureAndConceptsRefactoring = {
'/core-features/share-your-cache': '/core-features/remote-cache',
'/concepts/more-concepts/customizing-inputs':
'/recipes/running-tasks/customizing-inputs',
@ -899,6 +899,10 @@ const coreFeatureRefactoring = {
'/recipes/running-tasks/workspace-watching',
'/recipes/tips-n-tricks/reduce-repetitive-configuration':
'/recipes/running-tasks/reduce-repetitive-configuration',
'/concepts/more-concepts/global-nx':
'/getting-started/installation#installing-nx-globally',
'/concepts/more-concepts/nx-and-the-wrapper':
'/getting-started/installation#selfmanaged-nx-installation',
};
/*
@ -940,7 +944,7 @@ module.exports = {
makeMoreConceptsSubmenu,
pluginsToExtendNx,
latestRecipesRefactoring,
coreFeatureRefactoring,
coreFeatureRefactoring: coreFeatureAndConceptsRefactoring,
aiChat,
eslintRename,
};