[英]How to run Angular 2 app without browser-sync and node?
I have created an angular2 app with typescript. 我创建了一个带有打字稿的angular2应用程序。 I am using Angular2 Routes for routing.
我正在使用Angular2路由进行路由。 Using lite-server to start my angular2 app, it is working fine and routing properly if page is refreshed.
使用lite-server启动我的angular2应用程序,如果页面刷新,它工作正常并正确路由。
ISSUE:: 问题::
But once i deployed the ts-compiled code to my domain which uses http-server to serve the files, it stop routing properly. 但是,一旦我将ts编译的代码部署到使用http-server来提供文件的域中,它就会停止正确路由。
Whenever I refresh my page on my domain( blog.jyotirmaysenapati.com ), it shows below thing:: 每当我在我的域( blog.jyotirmaysenapati.com )上刷新我的页面时,它显示在下面的东西::
Not Found
未找到
The requested URL /blog/new was not found on this server.
在此服务器上找不到请求的URL / blog / new。
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误。
Please help on this as i do not want to have node support in my domain. 请帮忙,因为我不想在我的域中拥有节点支持。 So how can i run it properly without the help of node and browser-sync??
那么如何在没有节点和浏览器同步的帮助下正确运行它?
Is it possible in first case?? 在第一种情况下是否可能?
I am using latest version of angular2 framework.
我正在使用最新版本的angular2框架。
You can use gulp-connect which provide fallback option :- 你可以使用gulp-connect提供后备选项: -
var gulp = require('gulp'),
connect = require('gulp-connect');
gulp.task('connect',function() {
connect.server({
root: '',
port: 8080,
fallback: 'index.html',
middleware: function(connect) {
return [connect()
.use('/node_modules', connect.static('./node_modules')), connect()
.use('/app', connect.static('./dist'))
];
}
});
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.