npmyarnpkgnx.dev

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?


Solution

  • 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!