问题
I am getting the below mentioned error when I execute ng s --open command:
Cannot find module '@angular/compiler-cli' Error: Cannot find module '@angular/compiler-cli' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:655:15) at Function.Module._load (internal/modules/cjs/loader.js:580:25) at Module.require (internal/modules/cjs/loader.js:711:19) at require (internal/modules/cjs/helpers.js:14:16) at Object. (G:\Front-End\angular\rapydly\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:12:24) at Module._compile (internal/modules/cjs/loader.js:805:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10) at Module.load (internal/modules/cjs/loader.js:672:32) at tryModuleLoad (internal/modules/cjs/loader.js:612:12) at Function.Module._load (internal/modules/cjs/loader.js:604:3) at Module.require (internal/modules/cjs/loader.js:711:19) at require (internal/modules/cjs/helpers.js:14:16) at Object. (G:\Front-End\angular\rapydly\node_modules@ngtools\webpack\src\index.js:13:10) at Module._compile (internal/modules/cjs/loader.js:805:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10) at Module.load (internal/modules/cjs/loader.js:672:32) at tryModuleLoad (internal/modules/cjs/loader.js:612:12) at Function.Module._load (internal/modules/cjs/loader.js:604:3) at Module.require (internal/modules/cjs/loader.js:711:19) at require (internal/modules/cjs/helpers.js:14:16) at Object. (G:\Front-End\angular\rapydly\node_modules@angular-devkit\build-angular\src\angular-cli-files\models\webpack-configs\typescript.js:4:19) at Module._compile (internal/modules/cjs/loader.js:805:30)
This is my package.json file:
{
"name": "rapid",
"version": "1.1.9",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@asymmetrik/ngx-leaflet": "^4.0.0",
"@dvsl/zoomcharts": "^1.18.4",
"@ng-bootstrap/ng-bootstrap": "^4.0.3",
"@types/c3": "^0.6.0",
"angular-2-dropdown-multiselect": "^1.8.1",
"angular-confirmation-popover": "^4.2.0",
"angular-datatables": "^6.0.0",
"angular2-tag-input": "^1.2.3",
"angular2-toaster": "^6.1.0",
"aws-sdk": "^2.271.1",
"bootstrap": "^3.3.7",
"bootstrap-daterangepicker": "^3.0.3",
"c3": "^0.6.6",
"core-js": "^2.4.1",
"crypto-js": "^3.1.9-1",
"datatables.net": "^1.10.18",
"datatables.net-dt": "^1.10.18",
"file-saver": "^2.0.0",
"jquery": "^3.3.1",
"leaflet": "^1.3.4",
"moment": "^2.22.2",
"ng-multiselect-dropdown": "^0.1.9",
"ng-recaptcha": "^4.2.1",
"ng2-table": "^1.3.2",
"ng2-tooltip-directive": "^2.1.6",
"ngx-bootstrap": "^3.1.2",
"ngx-cookie-service": "^1.0.10",
"ngx-popover": "0.0.16",
"ngx-spinner": "^6.0.0",
"ngx-tooltip": "0.0.9",
"ngx-webstorage": "^2.0.1",
"popper.js": "^1.14.3",
"rxjs": "^5.5.6",
"tslib": "^1.9.0",
"xlsx": "^0.14.1",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.12.4",
"@angular/cli": "^7.2.1",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/datatables.net": "^1.10.11",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/jquery": "^3.3.4",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.4.0",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}
Can some one guide me as to what the issue is to get the error? I am working on the windows platform. I uninstalled the previous node version and installed the new version. Still it's giving the same error.
回答1:
By executing the npm i @angular/compiler-cli
everything is again working perfectly.
回答2:
Just follow steps ->
Delete your node_modules folder manually or rm -r node_modules
Clean npm cache -> npm cache clean
Install npm by running npm install
回答3:
I had the same issue when I was going to run my angular 7 application first time which was cloned from azure devops repository. Just executed the following command on node terminal in visual studio code and error was solved.
npm i @angular/compiler-cli
回答4:
This works:- npm i @angular/compiler-cli
来源:https://stackoverflow.com/questions/55606102/error-cannot-find-module-angular-compiler-cli