Welcome to the average.dev monorepo! Before you begin, ensure your local development environment is set up.
This repository enforces strict Node.js versioning via the .nvmrc file at the root. We strongly recommend using Fast Node Manager (fnm):
- Windows:
winget install Schniz.fnm - macOS/Linux:
brew install fnmor curl installation.
Once installed, ensure your terminal profile is configured for fnm. For PowerShell, you must run this to apply it to your current session, and also add it to your profile for future sessions:
# Apply to current session:
fnm env --use-on-cd | Out-String | Invoke-Expression
# Add to profile for future sessions:
notepad $PROFILE
# Add the line below to the bottom and save.
fnm env --use-on-cd | Out-String | Invoke-ExpressionAfter configuring your terminal, navigate to the repository root. If this is your first time setting up the repository, download the required Node version specified in .nvmrc:
fnm installfnm will now automatically switch to the correct Node version whenever you enter the directory.
We use Yarn as our package manager. With the correct Node version active via fnm, enable Yarn via Corepack:
corepack enable yarn
yarn installNote
Node.js ships with Corepack but it is opt-in by default. Running corepack enable yarn makes the yarn command available in your terminal without needing a global npm install, and guarantees you use the exact Yarn version specified in the project.
Warning
If you get an error saying corepack: The term 'corepack' is not recognized or yarn: The term 'yarn' is not recognized, it means fnm was not loaded into your current shell. You can fix this immediately by running:
fnm env --use-on-cd | Out-String | Invoke-ExpressionIf you are working on Go services within this monorepo, you need the Go toolchain installed:
- Windows: Download the MSI installer from go.dev/dl/.
- macOS:
brew install go - Verify installation by running
go version. We usegolangci-lintfor linting, which is configured via.golangci.yml.
✨ Your new, shiny Nx workspace is ready ✨.
Learn more about this workspace setup and its capabilities or run yarn nx graph to visually explore what was created. Now, let's get you up to speed!
To run tasks with Nx use:
npx nx <target> <project-name>For example:
npx nx build myprojectThese targets are either inferred automatically or defined in the project.json or package.json files.
More about running tasks in the docs »
While you could add new projects to your workspace manually, you might want to leverage Nx plugins and their code generation feature.
To install a new plugin you can use the nx add command. Here's an example of adding the React plugin:
npx nx add @nx/reactUse the plugin's generator to create new projects. For example, to create a new React app or library:
# Generate an app
npx nx g @nx/react:app demo
# Generate a library
npx nx g @nx/react:lib some-libYou can use npx nx list to get a list of installed plugins. Then, run npx nx list <plugin-name> to learn about more specific capabilities of a particular plugin. Alternatively, install Nx Console to browse plugins and generators in your IDE.
Learn more about Nx plugins » | Browse the plugin registry »
To connect to Nx Cloud, run the following command:
npx nx connectConnecting to Nx Cloud ensures a fast and scalable CI pipeline. It includes features such as:
- Remote caching
- Task distribution across multiple machines
- Automated e2e test splitting
- Task flakiness detection and rerunning
Use the following command to configure a CI workflow for your workspace:
npx nx g ci-workflowNx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
Learn more:
- Learn more about this workspace setup
- Learn about Nx on CI
- Releasing Packages with Nx release
- What are Nx plugins?
And join the Nx community: