ng2-ckeditor error找不到模块&模块的元数据版本不匹配

时间:2018-02-15 05:13:14

标签: angular npm-install

我在我的角度4项目上尝试ng serve,我看到了这个

ERROR in /var/www/penderie1/src/app/admin/admin.module.ts (20,32): Cannot find module 'ng2-ckeditor'.
ERROR in /var/www/penderie1/src/app/myaccount/myaccount.module.ts (6,32): Cannot find module 'ng2-ckeditor'.
ERROR in /var/www/penderie1/src/app/app.module.ts (6,32): Cannot find module 'ng2-ckeditor'.
ERROR in Error: Error encountered resolving symbol values statically. Could not resolve ng2-ckeditor relative to /var/www/penderie1/src/app/app.module.ts., resolving symbol AppModule in /var/www/penderie1/src/app/app.module.ts, resolving symbol AppModule in /var/www/penderie1/src/app/app.module.ts
    at syntaxError (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:1729:34)
    at simplifyInContext (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:24979:23)
    at StaticReflector.simplify (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:24991:13)
    at StaticReflector.annotations (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:24418:41)
    at _getNgModuleMetadata (/var/www/penderie1/node_modules/@angular/compiler-cli/src/ngtools_impl.js:138:31)
    at _extractLazyRoutesFromStaticModule (/var/www/penderie1/node_modules/@angular/compiler-cli/src/ngtools_impl.js:109:26)
    at Object.listLazyRoutesOfModule (/var/www/penderie1/node_modules/@angular/compiler-cli/src/ngtools_impl.js:53:22)
    at Function.NgTools_InternalApi_NG_2.listLazyRoutes (/var/www/penderie1/node_modules/@angular/compiler-cli/src/ngtools_api.js:91:39)
    at AotPlugin._getLazyRoutesFromNgtools (/var/www/penderie1/node_modules/@ngtools/webpack/src/plugin.js:212:44)
    at _donePromise.Promise.resolve.then.then.then.then.then (/var/www/penderie1/node_modules/@ngtools/webpack/src/plugin.js:448:24)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)

我不明白这个问题,因为我的配置文件中正确包含了ck-editor。 当我运行npm install ng-2-ckeditor --save并运行ng serve时,我会看到此错误

ERROR in Error: Metadata version mismatch for module /var/www/penderie1/node_modules/ng2-ckeditor/lib/ng2-ckeditor.d.ts, found version 4, expected 3, resolving symbol AppModule in /var/www/penderie1/src/app/app.module.ts, resolving symbol AppModule in /var/www/penderie1/src/app/app.module.ts
    at syntaxError (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:1729:34)
    at simplifyInContext (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:24979:23)
    at StaticReflector.simplify (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:24991:13)
    at StaticReflector.annotations (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:24418:41)
    at _getNgModuleMetadata (/var/www/penderie1/node_modules/@angular/compiler-cli/src/ngtools_impl.js:138:31)
    at _extractLazyRoutesFromStaticModule (/var/www/penderie1/node_modules/@angular/compiler-cli/src/ngtools_impl.js:109:26)
    at Object.listLazyRoutesOfModule (/var/www/penderie1/node_modules/@angular/compiler-cli/src/ngtools_impl.js:53:22)
    at Function.NgTools_InternalApi_NG_2.listLazyRoutes (/var/www/penderie1/node_modules/@angular/compiler-cli/src/ngtools_api.js:91:39)
    at AotPlugin._getLazyRoutesFromNgtools (/var/www/penderie1/node_modules/@ngtools/webpack/src/plugin.js:212:44)
    at _donePromise.Promise.resolve.then.then.then.then.then (/var/www/penderie1/node_modules/@ngtools/webpack/src/plugin.js:448:24)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)

2 个答案:

答案 0 :(得分:4)

安装ng2-ckeditor的1.1.9版。试试npm install ng2-ckeditor@1.1.9 --save

答案 1 :(得分:1)

兄弟,这是一个版本问题。 尝试更新 你的角度版本从4到5,如果它是4,否则尝试

try to use
"ng2-ckeditor": "1.1.9",
instead
"ng2-ckeditor": "^1.1.9",