Search code examples
angularangular-cliangular-upgrade

ng update @angular/core@10 @angular/cli@10 isn't working


I have an app that runs under the angular v9.1.11. I'm trying to update it to angular 12 with the following command ng update @angular/core@10 @angular/cli@10 like recommended on their website https://update.angular.io/?v=9.1-12.0.

But I get the following error.

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

Error: Cannot find module 'C:\Users\myUser\Documents\projects\myProject\myProject-name\'C:\Users\ULTRAS~1\AppData\Local\Temp\angular-cli-packages-UCf5Bu\node_modules\@angular\cli\bin\ng''
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
    at Function.Module._load (internal/modules/cjs/loader.js:730:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Solution

  • I had the angular v12 globally installed.

    I had to downgrade it to the version 10 with the following command npm install -g @angular/[email protected]

    Then I could run this again ng update @angular/core@10 @angular/cli@10 --force and it did worked.

    If you get the problem with the v11, run this npm install -g @angular/[email protected] instead

    Then do npm install -g @angular/cli@latest when you're done