Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nx.dev creating first app failure with cannot find module

In trying out nx.dev, I ran this command

npx nx generate @nrwl/node:app ghApi

and received this error

Unable to resolve @nrwl/node:app.
Cannot find module '@nrwl/node/package.json'
Require stack:
- /Users/dean/workspace/gazehealth/nxdev-workspace/node_modules/nx/src/utils/nx-plugin.js
- /Users/dean/workspace/gazehealth/nxdev- workspace/node_modules/nx/src/config/workspaces.js
- /Users/dean/workspace/gazehealth/nxdev-workspace/node_modules/nx/src/command- line/generate.js
- /Users/dean/workspace/gazehealth/nxdev-workspace/node_modules/nx/src/command-line/nx-commands.js
- /Users/dean/workspace/gazehealth/nxdev-workspace/node_modules/nx/bin/init-local.js
- /Users/dean/workspace/gazehealth/nxdev-workspace/node_modules/nx/bin/nx.js

I simply followed instructions from https://nx.dev/getting-started/nx-and-typescript any ideas?

like image 286
Dean Hiller Avatar asked Jul 10 '26 15:07

Dean Hiller


2 Answers

I had a similar issue.

Try: nx report

You will see something like this:

 >  NX   Report complete - copy this into the issue template

   Node : 16.15.0
   OS   : darwin x64
   npm  : 8.5.5
   
   nx : 14.2.2
   @nrwl/angular : 14.2.2
   @nrwl/cypress : 14.2.2
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.2.2
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 14.2.2
   @nrwl/js : Not Found
   @nrwl/linter : 14.2.2
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.2.2
   @nrwl/web : Not Found
   @nrwl/workspace : 14.2.2
   typescript : 4.7.3

In my case @nrwl/node was "not found"

So I just Installed it with: npm i @nrwl/node

And after that, the nx g @nrwl/node:app MyAppName worked.

I hope this can help!

like image 149
Yura Demkiv Avatar answered Jul 14 '26 00:07

Yura Demkiv


These issues are sometimes related to node versions. Check which node version you used to install the dependencies.

In my case, I used node 14 instead of node 16

After the node upgrade and reinstalling of all the node packages, the application did work fine.

like image 37
Gopet Avatar answered Jul 14 '26 02:07

Gopet