Cannot get on http://localhost:3000/
12,460
Solution 1
Since your baseDir is 'dist' you need to run http://localhost:3000/html in the browser I think that should work.
Solution 2
You need to point browserSync
to the dist/html/index.html
file as the start page with index
.
gulp.task('browser-sync',function(){
browserSync.init(null,{
open : false,
server : {
baseDir : 'dist',
index : "html/index.html"
}
});
console.log("finshed browser ");
});
Related videos on Youtube
Author by
FalconFlyer
Updated on June 04, 2022Comments
-
FalconFlyer about 2 years
I am using gulp.The tasks are getting run creating required folders. But I get Cannot GET/ error when run in browser.I have attached the image of my project structure and also the output in command line
.
.My index.html contains the following
<!DOCTYPE html> <html lang="en" ng-app="helloWorldApp"> <head> <title>Angular hello world app</title> <link href="css/main.css" rel="stylesheet"> </head> <body> <ng-view class="view"></ng-view> </body> <script src="js/scripts.js"></script> </html>
I want to know why it cannot get or not routed properly and what should be done. So the problem is when the server is running on localhost and I hit localhost:3000/ in browser it says cannot get with a white background.Following is my gulpfile.js
const gulp = require('gulp'); const concat = require('gulp-concat'); const browserSync = require('browser-sync').create(); const scripts = require('./scripts'); const styles = require('./styles'); var devMode = false; gulp.task('css',function(){ gulp.src(styles) .pipe(concat('main.css')) .pipe(gulp.dest('./dist/css')) .pipe(browserSync.reload({ stream : true })) }); gulp.task('js',function(){ gulp.src(scripts) .pipe(concat('scripts.js')) .pipe(gulp.dest('./dist/js')) .pipe(browserSync.reload({ stream : true })) }); gulp.task('html',function(){ gulp.src('./templates/**/*.html') .pipe(gulp.dest('./dist/html')) .pipe(browserSync.reload({ stream : true })) }); gulp.task('build',function(){ gulp.start(['css','js','html']); console.log("finshed build"); }); gulp.task('browser-sync',function(){ browserSync.init(null,{ open : false, server : { baseDir : 'dist' } }); console.log("finshed browser "); }); gulp.task('start',function(){ devMode = true; gulp.start(['build','browser-sync']); gulp.watch(['./css/**/*.css'],['css']); gulp.watch(['./js/**/*.js'],['js']); gulp.watch(['./templates/**/*.html'],['html']); });
-
lofihelsinki about 7 yearsAre you in the right directory? What does
http://localhost:3000
say if you enable directory listing? Replaceindex : "html/index.html"
withdirectory: true