“@angular/compiler-cli”包没有正确安装。错误:找不到模块'@angular/compiler-cli'

Posted

技术标签:

【中文标题】“@angular/compiler-cli”包没有正确安装。错误:找不到模块\'@angular/compiler-cli\'【英文标题】:The "@angular/compiler-cli" package was not properly installed. Error: Cannot find module '@angular/compiler-cli'“@angular/compiler-cli”包没有正确安装。错误:找不到模块'@angular/compiler-cli' 【发布时间】:2018-02-04 18:11:32 【问题描述】:

当尝试 npm startng serve 时,它会显示如下错误:

The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'    
Error: The "@angular/compiler-cli" package was not properly installed.     Error: Error: Cannot find module '@angular/compiler-cli'    
    at Object.     (/home/jsnsree/.nvm/versions/node/v6.11.2/lib/node_modules/@angular/cli/node_modules//src/index.js:14:11)    
at Module._compile (module.js:570:32)    
at Object.Module._extensions..js (module.js:579:10)    
at Module.load (module.js:487:32)    
at tryModuleLoad (module.js:446:12)    
at Function.Module._load (module.js:438:3)    
at Module.require (module.js:497:17)    
at require (internal/module.js:20:19)    
at Object.     (/home/jsnsree/.nvm/versions/node/v6.11.2/lib/node_modules/@angular/cli/tasks/eject.js:10:19)    
at Module._compile (module.js:570:32)    
at Object.Module._extensions..js (module.js:579:10)    
at Module.load (module.js:487:32)    
at tryModuleLoad (module.js:446:12)    
at Function.Module._load (module.js:438:3)    
at Module.require (module.js:497:17)    
at require (internal/module.js:20:19)    

我的应用程序中的 ng versoin 显示:

@angular/cli: 1.3.2    
node: 6.11.2     
os: linux x64     
@angular/animations: error     
@angular/common: error     
@angular/compiler: error     
@angular/core: error     
@angular/forms: error     
@angular/http: error     
@angular/platform-browser: error     
@angular/platform-browser-dynamic: error     
@angular/platform-server: error     
@angular/router: error     
@angular/cli: error     
@angular/compiler-cli: error    

我尝试删除并重新安装 angular/cli,但没有进行任何更改:

【问题讨论】:

【参考方案1】:

从你的项目中删除 node_modules 并运行

npm install

这会奏效

【讨论】:

【参考方案2】:

尝试重新安装您的 CLI。

npm uninstall -g @angular/cli

npm cache clean

npm install -g @angular/cli@latest

【讨论】:

以上是关于“@angular/compiler-cli”包没有正确安装。错误:找不到模块'@angular/compiler-cli'的主要内容,如果未能解决你的问题,请参考以下文章

运行 ng serve 时找不到模块“@angular/compiler-cli/ngc”

“npm install”没有正确安装@angular/cli、@angular/compiler-cli 和@angular-devkit/build-angular

ionic-app-script在构建时失败 - 无法找到模块'@ angular / compiler-cli / ngtools2'

qianduan

Angular中伊斯坦布尔覆盖报告中的标记异常

如何在 Angular cli 中启用 gzip 压缩以进行生产构建