Skip to content

01 NX Setup

JP Barbosa edited this page Apr 15, 2023 · 3 revisions

NX Setup

Install NX Globally

npm install -g nx

Create Workspace

npx create-nx-workspace@latest neo4j-crud --preset=ts

Obs.: Enable distributed caching to make your CI faster: No

Install Packages

cd neo4j-crud
npm install --save-dev @nrwl/node @nrwl/express @nrwl/react

Generate Packages

nx generate @nrwl/node:library shared
nx generate @nrwl/node:library graph
nx generate @nrwl/express:application api
nx generate @nrwl/react:application web

Obs.:

  • Which stylesheet format would you like to use? SASS
  • Would you like to add React Router to this application? Yes
  • Which bundler do you want to use to build the application? Vite

Set TS Target

code ./tsconfig.base.json
{
  "compileOnSave": false,
  "compilerOptions": {
    ...
    "target": "es2021",
    "module": "esnext",
    "lib": ["es2021", "dom"],
    ...
  },
  "exclude": ["node_modules", "tmp"]
}

Start All Applications

nx run-many --target=serve --all

Test API And Web Applications

open http://localhost:3333/api
open http://localhost:4200
API WEB

Commit

git add .
git commit -m "NX Setup"

Next step: Graph Database