During local development of a max application, a .nx
directory is created in the project for the app being developed. This app must be compiled before deployment to production by executing npm run build
. After compilation, an .output
directory is created, containing the production-ready app and a public
subdirectory for publicly accessible resources. The server
directory contains the server-side of the app and files with .mjs
extensions, indicating the use of JavaScript standard module system with export
and import
. To preview the compiled app locally, npm run preview
runs the server-side code using Node.js. An error regarding port 3000 being in use can occur if the development server is still running—stopping it then running npm run preview
again is necessary. Once the service starts, the application can be accessed on localhost at port 3000, displaying the production-ready nx application.