admin管理员组文章数量:1414621
Using Angular.
Steps:
Cloned this simple UI lib that demonstrates the current Angular package standards:
Created a new test app with
ng new testApp
npm link
thesimple-ui-lib/dist
npm link simple-ui-lib
in the testAppImported the example module from simple-ui-lib into testApp:
In the app.module.ts file:
import { BoxModule } from 'simple-ui-lib';
...
@NgModule({
...
imports: [
...
BoxModule
]
})
Webpack piles fine, but I get this error in the browser and nothing loads:
piler.es5.js:1540 Uncaught Error: Unexpected value 'BoxModule' imported by the module 'AppModule'. Please add a @NgModule annotation.
I've tried:
- Clearing my npm cache
- Re-installing all node modules
- Forcing all Angular modules to be the same version in both projects
- Checked that all Angular modules are the same version in both projects
- Checked that the TypeScript version is the same in both projects
- Using other sample module packages instead of
simple-ui-lib
- Created an entirely new project with the same setup
- Downgrading the
rollup
version used insimple-ui-lib
to a build from January
If I console log the BoxModule
, I can see the value exists and it seems to be registered as an @NgModule, so I'm confused about what this error is trying to tell me.
I've seen this error around in my searches, but it looks like they are almost always caused by a version mismatch between the library and the host application. In my case, the versions are the same.
Versions:
- TypeScript: 2.2.0
- @angular/cli: 1.0.4
- @angular/mon: 4.1.3
Any ideas?
Update: Investigating more, looks like this is a problem with @angular/cli itself. Opened a bug here: , but if you have any suggestions please let me know.
Using Angular.
Steps:
Cloned this simple UI lib that demonstrates the current Angular package standards: https://github./jasonaden/simple-ui-lib
Created a new test app with
ng new testApp
npm link
thesimple-ui-lib/dist
npm link simple-ui-lib
in the testAppImported the example module from simple-ui-lib into testApp:
In the app.module.ts file:
import { BoxModule } from 'simple-ui-lib';
...
@NgModule({
...
imports: [
...
BoxModule
]
})
Webpack piles fine, but I get this error in the browser and nothing loads:
piler.es5.js:1540 Uncaught Error: Unexpected value 'BoxModule' imported by the module 'AppModule'. Please add a @NgModule annotation.
I've tried:
- Clearing my npm cache
- Re-installing all node modules
- Forcing all Angular modules to be the same version in both projects
- Checked that all Angular modules are the same version in both projects
- Checked that the TypeScript version is the same in both projects
- Using other sample module packages instead of
simple-ui-lib
- Created an entirely new project with the same setup
- Downgrading the
rollup
version used insimple-ui-lib
to a build from January
If I console log the BoxModule
, I can see the value exists and it seems to be registered as an @NgModule, so I'm confused about what this error is trying to tell me.
I've seen this error around in my searches, but it looks like they are almost always caused by a version mismatch between the library and the host application. In my case, the versions are the same.
Versions:
- TypeScript: 2.2.0
- @angular/cli: 1.0.4
- @angular/mon: 4.1.3
Any ideas?
Update: Investigating more, looks like this is a problem with @angular/cli itself. Opened a bug here: https://github./angular/angular-cli/issues/6429, but if you have any suggestions please let me know.
Share Improve this question edited May 23, 2017 at 16:06 Mike asked May 23, 2017 at 14:55 MikeMike 4,09124 silver badges36 bronze badges 2- 1 This may help: github./angular/angular-cli/blob/master/docs/documentation/… – Ryan Commented Jul 17, 2017 at 13:21
- i'm having the same issue with a ChartsModule from ng2-charts.. it's only an issue on aot though. – JBoothUA Commented Dec 8, 2017 at 15:37
1 Answer
Reset to default 2Try to use es6 piler instead of es5. I encountered similar issue before and chaging the pilation mode solved the problem
I also remand you To use the last angular cli version and upgrade to angular 5
版权声明:本文标题:javascript - Unexpected value '...' imported by the module '...'. Please add a @NgModule annotat 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745176871a2646279.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论