Angular 2路由器:不能匹配任何路由

当试图在我的浏览器中加载localhost:3000 / verifyemail时,我收到错误:

错误:无法匹配任何路线

我已阅读了其他SO问题,并已validation以下内容:

  • Angular2:2.3.1默认使用path位置策略,我没有改变它。 我不喜欢使用哈希位置策略
  • 我已经configuration了我的Nodejs服务器的HTML5 pushState(server.js在下面)

    // Parsers for POST data app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); // Point static path to dist app.use(express.static(path.join(__dirname, 'dist'))); // Get API routes const api = require('./src/server/routes/api.js'); // Set api routes app.use('/api', api); // Catch all other routes and return the index file app.get('*', (req, res) => { res.sendFile(path.join(__dirname, 'dist/index.html')); }); const port = process.env.PORT || '3000'; app.set('port', port); const server = http.createServer(app); server.listen(port, () => console.log(`API running on localhost:${port}`)); 
  • 我在我的index.html中的<head>的顶部有<base href="/">

  • 我设置了默认和全部路由

     const appRoutes: Routes = [ { path: 'home', outlet: 'full-page', component: DefaultLandingPageComponent }, { path: 'verifyemail', outlet: 'full-page', component: EmailVerificationComponent }, { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: '**', outlet: 'full-page', component: DefaultLandingPageComponent } ]; 
  • 我已经将路由器模块导入到我的app.module.ts中,并在我的app.component.html文件中包含一个路由器sockets

     //in app.module.ts: @NgModule({ ... imports: [ ... RouterModule.forRoot(appRoutes) ] ... }); //in app.component.html import { RouterModule, Routes } from '@angular/router'; 

非常感谢谁能帮我一把!

更新1我已经删除了路由和路由器sockets上的所有名字,这要感谢GünterZöchbauer在下面的评论中的观察

更新2一切工作正常预期localhost:4200 / verifyemail,这是通过ng serve运行。 使用通过node server.js运行的localhost:3000 / verifyemail时,问题仍然存在

每条路线都需要一条路线,将一个组件添加到一个未命名的出口。 命名的网点只能用于一个无名网点,而不是。