简体   繁体   English

获取错误在 angular 8 中找不到模块“@angular/compiler-cli/ngcc”

[英]getting error Cannot find module '@angular/compiler-cli/ngcc' in angular 8

I am getting this error when I trying to run ng serve from my terminal window.当我尝试从终端窗口运行 ng serve 时出现此错误。

An unhandled exception occurred: Cannot find module '@angular/compiler-cli/ngcc'

Below is my package.json file下面是我的 package.json 文件

{
  "name": "ProjectDetails",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --extract-css",
    "build": "ng build --extract-css",
    "build:ssr": "npm run build -- --app=ssr --output-hashing=media",
    "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/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/platform-server": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@nguniversal/module-map-ngfactory-loader": "^5.0.0-beta.5",
    "aspnet-prerendering": "^3.0.1",
    "bootstrap": "^3.4.1",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.6",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.803.1",
    "@angular/cli": "^8.3.1",
    "@angular/compiler-cli": "^5.2.11",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^5.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.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.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  },
  "optionalDependencies": {
    "node-sass": "^4.9.0"
  }
}

My angular global version matches the angular/cli version in package .json.我的 angular 全局版本与包 .json 中的 angular/cli 版本匹配。 They both are 8.3.1.它们都是 8.3.1。 Below is the image for ng --version.下面是 ng --version 的图像。 I did both the command below, but still getting the same error:我执行了以下两个命令,但仍然出现相同的错误:

npm uninstall -g @angular/cli
npm install -g @angular/cli

any help will be higly appreciated.任何帮助将不胜感激。

在此处输入图片说明

After running these:运行这些后:

npm uninstall -g @angular/cli
npm install -g @angular/cli

Do this:做这个:

npm install

If npm audit fix is prompted, run it.如果提示npm audit fix ,请运行它。

I think your problem is with your versions.我认为您的问题出在您的版本上。 I mean you are using so many different versions and they could not work well together我的意思是你使用了这么多不同的版本,它们不能很好地协同工作

let me explain:让我解释:

Angular CLI: 8.3.5 (latest version) Angular CLI:8.3.5(最新版本)

but for cdk, for 1 year ago: "@angular/cdk": "^6.4.2", "@angular/common": "^6.1.0",但是对于 cdk,一年前:“@angular/cdk”:“^6.4.2”,“@angular/common”:“^6.1.0”,

typescript: 3.5.3 ( which probably wasn't there when angular 6.4 exist)打字稿:3.5.3(当 angular 6.4 存在时可能不存在)

try what I suggest: (I struggled so many times with old project)尝试我的建议:(我在旧项目上挣扎了很多次)

Lucky shot: just run ng update --all=true --force=true (look at documentation for correct syntax) it might work, but even if it throw some exceptions, it provide guidelines which reference has a problem)幸运的是:只需运行 ng update --all=true --force=true (查看文档以获取正确的语法)它可能会工作,但即使它抛出一些异常,它也提供了参考有问题的指南)

Create a new angular project by using "ng new projectname"使用“ng new projectname”创建一个新的角度项目

a.一种。 Use "ng serve" to start your project If it works fine, you will be sure that your npm and node works fine (which is very important because it eliminates so many bug possibilities) (if it isn't, honestly reinstalling windows is almost fastest way)使用“ng serve”启动你的项目如果它工作正常,你将确保你的npm和node工作正常(这非常重要,因为它消除了很多错误的可能性)(如果不是,老实说重新安装windows几乎是最快的方式)

b.after having a working template, just start adding other references to be sure that you dont have version mismatch (and don't forget ng serve and watching the output result).有了工作模板后,只需开始添加其他引用以确保您没有版本不匹配(并且不要忘记 ng serve 并观察输出结果)。 If you had version mismatch, try to upgrade them, or if not possible remove them (if it's an old library, you have to replace it anyway)如果您的版本不匹配,请尝试升级它们,或者如果不可能将它们删除(如果它是旧库,则无论如何都必须替换它)

c. C。 If it works with any problems, then ship your old code to this new folder and to try to remove your bugs如果它有任何问题,请将旧代码发送到这个新文件夹并尝试删除您的错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到模块“@angular/compiler-cli/ngcc” - Cannot find module '@angular/compiler-cli/ngcc' 在 ng serve 找不到模块“@angular/compiler-cli/ngcc” - Cannot find module '@angular/compiler-cli/ngcc' at ng serve Ionic4 / Angular - 在 Ionic 服务上找不到模块“@angular/compiler-cli/ngcc” - Ionic4 / Angular - Cannot find module '@angular/compiler-cli/ngcc' on Ionic serve 在我的应用程序上运行“ng serve”时“找不到模块‘@angular/compiler-cli/ngcc’” - "Cannot find module '@angular/compiler-cli/ngcc'" when running "ng serve" on my app 发生未处理的异常:找不到模块'@angular/compiler-cli/ngcc' - An unhandled exception occurred: Cannot find module '@angular/compiler-cli/ngcc' 我正在获取找不到模块'@ angular / compiler-cli' - I am getting the cannot find module '@angular/compiler-cli' 错误:找不到模块'@angular/compiler-cli - Error: Cannot find module '@angular/compiler-cli 错误:找不到模块'@angular/compiler-cli/linker' - Error: Cannot find module '@angular/compiler-cli/linker' 为什么我的 Angular CLI 找不到模块“@angular/compiler-cli/ngcc”? - Why cant my Angular CLI find module '@angular/compiler-cli/ngcc'? 找不到模块'@ angular / compiler-cli / ngtoolds2' - Cannot find module '@angular/compiler-cli/ngtoolds2'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM