1

Both project have same angular cli versions '7.2.0' Its First time we are facing this issue any one know what is the next way forword to fix this situation.Here is the json file of real working project.

  "name": "financial-service",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.2.12",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "bootstrap": "^3.4.1",
    "chart.js": "^2.9.2",
    "core-js": "^2.5.4",
    "file-saver": "^2.0.2",
    "ng2-charts": "^2.0.0",
    "ngx-pagination": "^4.1.0",
    "ngx-toastr": "^10.1.0",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "xlsx": "^0.15.1",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.12.0",
    "@angular/cli": "~7.2.0",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.2.2"
  }
}

And Here is the package.json file of test project

  "name": "ag-grid-example",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "@ng-select/ng-select": "^3.7.2",
    "@progress/kendo-angular-common": "^1.2.1",
    "@progress/kendo-angular-dateinputs": "^4.2.1",
    "@progress/kendo-angular-dropdowns": "^4.2.4",
    "@progress/kendo-angular-intl": "^2.0.1",
    "@progress/kendo-angular-l10n": "^2.0.1",
    "@progress/kendo-angular-popup": "^3.0.5",
    "@syncfusion/ej2-angular-dropdowns": "^17.4.47",
    "ag-grid-angular": "^22.1.1",
    "ag-grid-community": "^22.1.1",
    "angular2-multiselect-dropdown": "^4.6.3",
    "bootstrap": "^4.0.0",
    "core-js": "^2.5.4",
    "ng-multiselect-dropdown-angular7": "^0.1.5",
    "ngx-google-places-autocomplete": "^2.0.4",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.12.0",
    "@angular/cli": "~7.2.0",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.2.2"
  }
}

All multiselect Dropdown packages are working in test project but when we run ng serve in actual project

Error: Cannot find module 'ajv'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:6
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
t\core\src\json\schema\registry.js:10:13)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)```[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/6w2vP.png


Awais Khan
  • 25
  • 4

2 Answers2

0

Looks like a webpack issue. Follow the below steps.

  1. delete node_modules in the project
  2. npm cache verify
    3.npm install

For more details refer this

nbsamurai
  • 346
  • 4
  • 13
0

i cant find jav from your package.json and you use then inside code. my idea is you can install again npm install --save-dev ajv@6.5.5 and if dont fixed your problem try to delete node_modules in the project npm cache verify next go on npm install

nima amr
  • 603
  • 1
  • 6
  • 13