ng2-eonasdan-datetimepicker错误中的ERROR遇到静态解析符号值。调用函数'makeDecorator'

时间:2017-04-03 17:12:52

标签: angular eonasdan-datetimepicker ng-modules

我一直在尝试使用ng2-eonasdan-datetimepicker,但运气不好。这是正在发生的事情:

Z:\Dashboard>npm start

> dashboard@0.0.0 start Z:\Dashboard
> ng serve

** NG Live Development Server is running on http://localhost:4200 **
Hash: 8c10d4427bac000e3cf8
Time: 14549ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 206 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 37.4 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 5.28 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

ERROR in A2Edatetimepicker is not an NgModule
webpack: Failed to compile.

然后我在我的项目中打开任何文件,不对代码进行任何更改,只需在某处放置一个空格并保存以便重新编译,它就可以了!但它不会ng build。当我尝试构建项目时,我收到此错误:

ERROR in Unexpected value 'A2Edatetimepicker in Z:/Dashboard/node_modules/ng2-eonasdan-datetimepicker/dist/datetimepicker.module.d.ts' imported by the module 'AppModule in Z:/Dashboard/src/app/app.module.ts'. Please add a @NgModule annotation.

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'Z:\Dashboard\src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts

在我的日历组件中:

import * as datetimepicker from 'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js';

和我的app.module.ts:

import { A2Edatetimepicker } from 'ng2-eonasdan-datetimepicker/dist/datetimepicker.module';

imports: [
  A2Edatetimepicker
]

这就是它的要点。谁知道我做错了什么?

测试1 变化:

import { A2Edatetimepicker } from 'ng2-eonasdan-datetimepicker/dist/datetimepicker.module';
to
import { A2Edatetimepicker } from 'ng2-eonasdan-datetimepicker';

新错误:

ERROR in Error encountered resolving symbol values statically. Calling function 'makeDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol Injectable in Z:/Dashboard/node_modules/ng2-eonasdan-datetimepicker/node_modules/@angular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in Z:/Dashboard/node_modules/ng2-eonasdan-datetimepicker/node_modules/@angular/core/src/di/opaque_token.d.ts, resolving symbol OpaqueToken in Z:/Dashboard/node_modules/ng2-eonasdan-datetimepicker/node_modules/@angular/core/src/di/opaque_token.d.ts

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'Z:\Dashboard\src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts

新信息:

我发现如果我使用ng build --prod --aot false,我会收到不同的错误:

ERROR in A2Edatetimepicker is not an NgModule

找不到解决方案,但这暂时有效...... 我改变了:

import { A2Edatetimepicker } from 'ng2-eonasdan-datetimepicker/dist/datetimepicker.module';

imports: [
  A2Edatetimepicker
]
to

import { DateTimePickerDirective } from 'ng2-eonasdan-datetimepicker/dist/datetimepicker.directive.js';

declarations: [
  DateTimePickerDirective
]

并且只有ng build --prod --aot false才有效。我认为不会为最终版本做到这一点。至少我现在可以继续努力。但这个问题肯定仍然存在。当我使用ng build --prod时,我仍然会收到上述错误:

ERROR in Error encountered resolving symbol values statically. Calling function 'makeDecorator'...........

任何人都知道如何解决这个问题?

0 个答案:

没有答案