Search code examples
angularnrwl-nx

Why am i getting error on using any `nx` commands


Command used : nx

internal/modules/cjs/loader.js:983
  throw err;
  ^

Error: Cannot find module '@nrwl/workspace/src/command-line/supported-nx-commands'
Require stack:
- /Users/shawntony/projects/ktp-web/node_modules/@nrwl/cli/lib/init-local.js
- /Users/shawntony/projects/ktp-web/node_modules/@nrwl/cli/bin/nx.js
- /usr/local/lib/node_modules/@nrwl/cli/lib/init-global.js
- /usr/local/lib/node_modules/@nrwl/cli/bin/nx.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.initLocal (/Users/shawntony/projects/ktp-web/node_modules/@nrwl/cli/lib/init-local.js:12:33)
    at Object.<anonymous> (/Users/shawntony/projects/ktp-web/node_modules/@nrwl/cli/bin/nx.js:12:18)
    at Module._compile (internal/modules/cjs/loader.js:1151:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/shawntony/projects/ktp-web/node_modules/@nrwl/cli/lib/init-local.js',
    '/Users/shawntony/projects/ktp-web/node_modules/@nrwl/cli/bin/nx.js',
    '/usr/local/lib/node_modules/@nrwl/cli/lib/init-global.js',
    '/usr/local/lib/node_modules/@nrwl/cli/bin/nx.js'
  ]
}

Solution

  • Just had this issue myself. Fixed it by deleting all my node_modules, verifying npm cache, updating my global @nrwl-cli, and reinstalling. In short:

    1. rm -rf node_modules
    2. npm cache verify
    3. npm install -g @nrwl/cli
    4. npm install

    Not sure of what did the trick, but I suppose it some kind of inconsistency in some @nrwl module version in the project or in the cache.