In my NX monorepo, I had a project called grocery-shop that used nestjs as the backend API. Wanting to add a frontend, I introduced React to the project. However, after creating a new project within the monorepo using
nx g @nrwl/react:app grocery-shop-webapp
, I encountered issues running either (nx serve grocery-shop
).
An error message popped up:
NX Cannot read properties of undefined (reading 'projects')
My nx.json file was structured like this:
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"npmScope": "grocery-shop",
...
}
...
quot;npmScope": "grocery-shop",
"projects": {
"grocery-shop": {
"root": "apps/grocery-shop",
"tags": []
},
"grocery-shop-webapp": {
"root": "apps/grocery-shop-webapp",
"tags": []
}
}
...
To resolve the issue, I manually added the "projects" option in the file.
However, when attempting to run nx serve grocery-shop
, another error surfaced:
NX As of Nx 13, project configuration should be moved from nx.json to workspace.json/project.json. Please run "nx format" to fix this.
NX Cannot find configuration for task grocery-shop:serve
Running nx format
did not solve the problem.
I seek assistance in successfully running both applications.
EDIT:
nx report
output:
npm : 9.2.0
nx : 15.3.3
@nrwl/angular : Not Found
...
typescript : 4.9.4
SOLUTION:
Executing nx migrate latest
updated the version of NX and its dependencies, rectifying the dependency version mismatches identified by @Craigory Coppola.