• 欢迎访问少将全栈,学会感恩,乐于付出,珍惜缘份,成就彼此、推荐使用最新版火狐浏览器和Chrome浏览器访问本网站。
  • 吐槽,投稿,删稿,交个朋友,商务沟通v:ai_draw
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏少将全栈吧

angular编译出错解决办法Angular Compiler was detected but it was an

开发笔记 admin 6年前 (2017-12-10) 5357次浏览 已收录 2个评论 扫描二维码
ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2017-12-10T11:30:25.965Z
Hash: 31f71472581894cb8296
Time: 6476ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 3.43 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 1.01 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 33.7 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 856 kB [initial] [rendered]

ERROR in ./src/main.ts
Module build failed: Error: Angular Compiler was detected but it was an instance of the wrong class.
This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies.
    at Object.ngcLoader (D:web_srcHelloAngular
[email protected]:458:19)
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
ERROR in ./src/polyfills.ts
Module build failed: Error: Angular Compiler was detected but it was an instance of the wrong class.
This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies.
    at Object.ngcLoader (D:web_srcHelloAngular
[email protected]:458:19)
 @ multi ./src/polyfills.ts

webpack: Failed to compile.

npm ls @ngtools/webpack
[email protected] D:web_srcHelloAngular
+-- UNMET PEER DEPENDENCY @angular-devkit/[email protected] extraneous
+-- @angular/[email protected]
| +-- UNMET PEER DEPENDENCY @angular-devkit/[email protected] -> D:web_srcHelloAngular
ode_modules\_@[email protected]@@angular-devkitschematics
| | `-- UNMET PEER DEPENDENCY @angular-devkit/[email protected]
| `-- @ngtools/[email protected]  -> D:web_srcHelloAngular
ode_modules\_@[email protected]@@ngtoolswebpack
`-- @ngtools/[email protected]  extraneous

npm ERR! peer dep missing: @angular-devkit/[email protected], required by @schematics/[email protected]
npm ERR! extraneous: @ngtools/[email protected] D:web_srcHelloAngular
ode_modules@ngtoolswebpack
npm ERR! peer dep missing: @angular-devkit/[email protected], required by @schematics/[email protected]

ng -v
_                      _                 ____ _     ___
/    _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
/ △  | ’_  / _` | | | | |/ _` | ’__|   | |   | |    | |
/ ___ | | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
|___/

Angular CLI: 1.6.0
Node: 6.11.1
OS: win32 x64
Angular: 5.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.0
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.41
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.10
@schematics/schematics: 0.0.10
typescript: 2.4.2
webpack: 3.10.0

ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2017-12-10T11:44:35.998Z
Hash: 78b77921384d5e249049
Time: 12806ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 20.8 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 560 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 34.6 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 7.14 MB [initial] [rendered]

webpack: Compiled successfully.




直接暴力解决,删掉node_modules,重新cnpm i

I recently had a similar problem with @angular/[email protected] and @ngtools/[email protected]

├─┬ @angular/[email protected]
│ └── @ngtools/[email protected]
└── @ngtools/[email protected]
Follow the instructions here https://github.com/angular/angular-cli/wiki/stories-1.0-update 
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli

npm uninstall -g @angular/cli
npm uninstall --save-dev @angular/cli 

rm -rf node_modules dist
npm cache clean

npm install -g @angular/cli@latest
npm install --save-dev @angular/cli@latest
npm install   
https://stackoverflow.com/questions/46188636/module-build-failed-error-aotplugin-was-detected-but-it-was-an-instance-of-the

喜欢 (0)
[🍬谢谢你请我吃糖果🍬🍬~]
分享 (0)
关于作者:
少将,关注Web全栈开发、项目管理,持续不断的学习、努力成为一个更棒的开发,做最好的自己,让世界因你不同。
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(2)个小伙伴在吐槽
  1. 还搞Angular?
    robin2019-05-23 10:55 回复 Windows 10 | Chrome 73.0.3683.103
    • 有些项目是angular的哈。
      admin2019-05-26 08:26 回复 Mac OS X | Chrome 74.0.3729.169