nx: nx migrate Cannot find module @angular-devkit/architect

I’m trying to migrate from 11.0 to 11.2.

I’m getting following error:

Running migration rename-workspace-schematic-script
Cannot find module '@angular-devkit/architect'
Require stack:
- /private/var/folders/qg/mf99k0fs14g8sptzqrsp0_nr0000gn/T/tmp-5948XY2ZBOgXzEfX/node_modules/@nrwl/tao/src/commands/ngcli-adapter.js
- /private/var/folders/qg/mf99k0fs14g8sptzqrsp0_nr0000gn/T/tmp-5948XY2ZBOgXzEfX/node_modules/@nrwl/tao/src/commands/migrate.js
- /private/var/folders/qg/mf99k0fs14g8sptzqrsp0_nr0000gn/T/tmp-5948XY2ZBOgXzEfX/node_modules/@nrwl/tao/index.js
Command failed: /var/folders/qg/mf99k0fs14g8sptzqrsp0_nr0000gn/T/tmp-5948XY2ZBOgXzEfX/node_modules/.bin/tao migrate --run-migrations=migrations.json

I tried to add the package to the dev dependencies, but it did not change anything.

Environment:

Node : 14.15.4
  OS   : darwin x64
  npm  : 6.14.11
  
  nx : Not Found
  @nrwl/angular : 11.2.0
  @nrwl/cli : 11.2.0
  @nrwl/cypress : 11.2.0
  @nrwl/devkit : 11.2.0
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 11.2.0
  @nrwl/linter : 11.2.0
  @nrwl/nest : 11.2.0
  @nrwl/next : Not Found
  @nrwl/node : 11.2.0
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 11.2.0
  @nrwl/web : Not Found
  @nrwl/workspace : 11.2.0
  typescript : 4.0.5

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 33 (5 by maintainers)

Most upvoted comments

You should know I’m experiencing the same problem too. btw, in case someone is curious, I’m vegan!

Leaving a comment to keep the issue alive. @FrozenPandaz could you take another look at this?

I’m having a similar issue with latest Nx version (12.3.4). In my case the error comes up when trying to run the @nrwl/react-native:start builder:

Cannot find module '@angular-devkit/architect'
Require stack:
- \node_modules\@nrwl\tao\src\commands\ngcli-adapter.js
- \node_modules\@nrwl\tao\src\commands\run.js
- \node_modules\@nrwl\tao\index.js
- \node_modules\@nrwl\cli\lib\run-cli.js

As far as I can tell, the root cause of the error is that @nrwl/tao uses @angular-devkit/architect without declaring it as dependency. The code that imports @angular-devkit/architect is located in ngcli-adapter.ts:

https://github.com/nrwl/nx/blob/c71137f34cd687f6b38b96d60c9b7b17deacdf17/packages/tao/src/commands/ngcli-adapter.ts#L39-L43

Resolved this with below npm installation npm install --save-dev @angular-devkit/architect

This still happens in 15.0.0 while I’m trying to run e2e tests with @nrwl/cypress leveraging a library built with @nrwl/js:tsc

Error: Build failed with 19 errors:
../../node_modules/.pnpm/@nrwl+devkit@15.0.0_nx@15.0.0+typescript@4.8.4/node_modules/@nrwl/devkit/src/utils/convert-nx-executor.js:40:19: ERROR: Could not resolve "@angular-devkit/architect"
../../node_modules/.pnpm/nx@15.0.0/node_modules/nx/src/adapter/ngcli-adapter.js:6:23: ERROR: Could not resolve "@angular-devkit/core"
../../node_modules/.pnpm/nx@15.0.0/node_modules/nx/src/adapter/ngcli-adapter.js:8:23: ERROR: Could not resolve "@angular-devkit/core/node"
../../node_modules/.pnpm/nx@15.0.0/node_modules/nx/src/adapter/ngcli-adapter.js:21:38: ERROR: Could not resolve "@angular-devkit/architect"
../../node_modules/.pnpm/nx@15.0.0/node_modules/nx/src/adapter/ngcli-adapter.js:22:63: ERROR: Could not resolve "@angular-devkit/architect/node"
...

package.json:

    "@nrwl/cli": "15.0.0",
    "@nrwl/cypress": "15.0.0",
    "@nrwl/devkit": "15.0.0",
    "@nrwl/js": "15.0.0",
    "@nrwl/workspace": "15.0.0",
    "nx": "15.0.0"

Project is not an Angular application.

I woulder why @angular-devkit/architect is a dependency for my project since I haven’t use angular, I’m using react!

Same issue here with v12

@FrozenPandaz I fixed the problem doing this

npx create-nx-workspace of5
npm install -g @nrwl/schematics
npm install -g nx
npm install -D @nrwl/angular
npm install --save-dev @angular-devkit/architect
npm install -D @nrwl/nest

I think it was fixed but the issue occurs again.

@FrozenPandaz bumping this issue because in latest version 11.4.0 the dependencies for @angular-devkit/architect were removed once again in this commit.

This should be fixed in version 11.2.5 please try again with that version.

EDIT: For me, the problem was that the @angular-devkit/architect’s init has not been fired automatically (I do not know if t needs to start automatically, or the problem was that the package was alread installed globally). So I had to execute: nx g @nrwl/angular:init After this, it worked.

Same issue here, when following official nx mfe guide (https://nx.dev/l/a/guides/setup-mfe-with-angular)

nx run login:serve:development Cannot find module ‘@angular-devkit/architect’ Require stack:

  • C:\node14\node_modules@nrwl\angular\src\builders\webpack-server\webpack-server.impl.js
  • C:\node14\nx13mfe\node_modules@angular-devkit\architect\node\node-modules-architect-host.js
  • C:\node14\nx13mfe\node_modules@angular-devkit\architect\node\index.js
  • C:\node14\nx13mfe\node_modules@nrwl\tao\src\commands\ngcli-adapter.js
  • C:\node14\nx13mfe\node_modules@nrwl\tao\src\commands\run.js
  • C:\node14\nx13mfe\node_modules@nrwl\tao\index.js
  • C:\node14\nx13mfe\node_modules@nrwl\cli\lib\run-cli.js

I hit this today migrating from 11.2.12 to 11.5.2. Any updates @FrozenPandaz and @vsavkin?

It ran fine after migrating, but that is because it still existed in node_modules. However, once clearing it out I encountered the failure. Should the dependency be restored in the commit mentioned by @noviadi, or do developers need to manually added it to their project?