0

I am trying to update a project which was developed with angular 11 version. Now I would like to update the version to 12. So I ran the command ng update @angular/core@12 @angular/cli@12. But each time the below error occurs.

E:\Workspace\My Projects\CashFlow-Web>ng update @angular/core@12 @angular/cli@12 The installed local Angular CLI version is older than the latest stable version. Installing a temporary version to perform the update. √ Package successfully installed. internal/modules/cjs/loader.js:888 throw err; ^

Error: Cannot find module 'E:\Workspace\My Projects\CashFlow-Web'C:\Users\Nasir\AppData\Local\Temp\angular-cli-packages-kgrL8I\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: [] }

enter image description here

I did remove the package-lock.json file and node_modules folder and ran the npm install command but it still appears the above problem when I ran the update command. Please help me find the solution.

Here is my Package.json file:

{
  "name": "e-cash",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "generateData": "node server/generateData.js > server/database.json",
    "server": "json-server --watch server/database.json"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^11.2.14",
    "@angular/cdk": "^12.0.4",
    "@angular/common": "~11.2.9",
    "@angular/compiler": "~11.2.9",
    "@angular/core": "~11.2.9",
    "@angular/forms": "~11.2.9",
    "@angular/localize": "^11.2.9",
    "@angular/platform-browser": "~11.2.9",
    "@angular/platform-browser-dynamic": "~11.2.9",
    "@angular/router": "~11.2.9",
    "@ng-bootstrap/ng-bootstrap": "^8.0.0",
    "angular-ng-stepper": "^1.0.6",
    "angular2-multiselect-dropdown": "^4.6.10",
    "bootstrap": "^4.5.0",
    "faker": "^5.1.0",
    "google-libphonenumber": "^3.2.21",
    "intl-tel-input": "^17.0.13",
    "json-server": "^0.16.3",
    "moment": "^2.29.1",
    "ng-month-picker": "^1.1.5",
    "ng-multiselect-dropdown": "^0.3.4",
    "ngx-bootstrap": "^6.2.0",
    "ngx-currency": "^2.5.2",
    "ngx-image-cropper": "^3.3.5",
    "ngx-intl-tel-input": "^3.1.1",
    "ngx-perfect-scrollbar": "^10.1.0",
    "ngx-spinner": "^11.0.1",
    "ngx-toastr": "^14.0.0",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1102.8",
    "@angular/cli": "~11.2.8",
    "@angular/compiler-cli": "~11.2.9",
    "@types/node": "^12.11.1",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.2"
  }
}

angular.json file

 {
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "e-Cash": {
      "projectType": "application",
      "schematics": {},
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/e-Cash",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "node_modules/angular2-multiselect-dropdown/themes/default.theme.css",
              "node_modules/ngx-toastr/toastr.css",
              "node_modules/intl-tel-input/build/css/intlTelInput.css",
              "src/styles.css"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb",
                  "maximumError": "10kb"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "e-Cash:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "e-Cash:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "e-Cash:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "e-Cash:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "e-Cash:serve:production"
            }
          }
        }
      }
    }
  },
  "defaultProject": "e-Cash",
  "cli": {
    "analytics": "573cd480-259c-4d50-b647-d0a80a34b23a"
  }
}
mnu-nasir
  • 1,642
  • 5
  • 30
  • 62
  • It appear as though you have a strange reference in out of your modules. Perhaps you have something like `import { something } from 'ng';`. Or you have a reference to an internally-controlled module that's been removed. Really, it's a matter of going through your files and finding the offending module reference. – Heretic Monkey Aug 13 '21 at 17:35
  • Are you using Typescript 4.2 + ? And is your Node.js version 11+? – H3AR7B3A7 Aug 13 '21 at 17:36
  • I am using typescript 4.2 and NodeJs is 14.17.0 – mnu-nasir Aug 13 '21 at 17:38
  • use `--force ` while updating – Manojkumar Muthukumar Aug 13 '21 at 18:05
  • using --force command didn't work – mnu-nasir Aug 13 '21 at 18:18
  • 1
    `ng update` is not reliable to do all the work for us. Try checking your deps with NCU https://www.npmjs.com/package/npm-check-updates and of course make sure to delete package-lock files and node_modules before a fresh reinstall. – Ben Racicot Aug 13 '21 at 18:46
  • Please do not use force flag unless it is that much necessary. Some file is missing which is needed in your project. You have to manually check and continue updating. Cannot find module 'E:\Workspace\My Projects\primeng-tablefilter-demo' - This is the main issue. – vsnikhilvs Aug 14 '21 at 03:26

1 Answers1

0

you need to install dependencies

npm install

  • If you have a new question, please ask it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/late-answers/30189714) – Louay Sleman Oct 27 '21 at 10:53