angular-cli版本升级后错误

node:v7.4.0
npm:4.0.5

1.ERROR in Cannot use ‘in’ operator to search for ‘providers’ in null
这个错误,需要将
export default RouterModule.forRoot(appRoutes);
改成export const appRoutes = [{
path:”,
component:AppComponent
}]
然后在module中,先导入appRoutes,然后在imports配置中使用
RouterModule.forRoot(appRoutes)即可

2。ERROR in default is not an NgModule
这个错误是因为在module文件中使用了export default 导出导致的,
需要将default去掉,在路由的loadChildren配置中添加#ModuleName如果没有在loadChildren配置中加#ModuleName,也会报这个错误

例如:
{
path:’post’,
loadChildren:’./post/post.module#PostModule’
}

package.json的依赖部分贴出来

“dependencies”: {
“@angular/common”: “2.4.2”,
“@angular/compiler”: “2.4.2”,
“@angular/core”: “2.4.2”,
“@angular/forms”: “2.4.2”,
“@angular/http”: “2.4.2”,
“@angular/platform-browser”: “2.4.2”,
“@angular/platform-browser-dynamic”: “2.4.2”,
“@angular/router”: “3.4.2”,
“core-js”: “^2.4.1”,
“ng2-bootstrap”: “^1.1.5”,
“portfinder”: “^1.0.9”,
“rxjs”: “5.0.3”,
“tinymce”: “^4.5.0”,
“ts-helpers”: “^1.1.1”,
“zone.js”: “^0.7.2”
},
“devDependencies”: {
“@types/jasmine”: “^2.2.30”,
“angular-cli”: “^1.0.0-beta.24”,
“codelyzer”: “~0.0.26”,
“jasmine-core”: “2.4.1”,
“jasmine-spec-reporter”: “2.5.0”,
“karma”: “1.2.0”,
“karma-chrome-launcher”: “^2.0.0”,
“karma-cli”: “^1.0.1”,
“karma-jasmine”: “^1.0.2”,
“karma-remap-istanbul”: “^0.2.1”,
“protractor”: “4.0.5”,
“ts-node”: “1.2.1”,
“tslint”: “3.13.0”,
“typescript”: “2.0.10”
}
对我有帮助的文章
https://github.com/angular/angular-cli/issues/3826

你可能感兴趣的:(前端开发)