nodejs server cannot get /html

266
April 10, 2018, at 04:36 AM

Server.js file:

var express = require('express');
var app = express();
app.set('port', (process.env.PORT || 3000));
app.use('/', express.static(__dirname));
app.listen(app.get('port'), function() {
  console.log('Server started: http://localhost:' + app.get('port') + '/');
});

package.json file

    {
  "name": "myproject",
  "version": "1.0.0",
  "description": "my final work",
  "main": "./app/index.html",
  "dependencies": {
    "babel-standalone": "^6.26.0",
    "bower": "^1.8.4",
    "npm": "^5.8.0",
    "slick-carousel": "^1.8.1"
  },
  "devDependencies": {
    "babel-preset-env": "^1.6.1",
    "browser-sync": "^2.23.6",
    "express": "^4.16.3",
    "gulp": "^3.9.1",
    "gulp-concat": "^2.6.1",
    "gulp-cssnano": "^2.1.2",
    "gulp-nodemon": "^2.2.1",
    "gulp-rename": "^1.2.2",
    "gulp-sass": "^3.2.1",
    "gulp-uglifyjs": "^0.6.2"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
  },
  "author": "furymaxim",
  "license": "ISC"
}

gulpfile

var gulp = require('gulp'),  //Require говорит Node.js проверить папку node_modules и найти там папку gulp.
    sass = require('gulp-sass'),
    browserSync = require('browser-sync'),  //rowser Sync уже работает с Gulp, и нет нужды gulp-
    concat = require('gulp-concat'),
    uglify = require('gulp-uglifyjs'),
    cssnano = require('gulp-cssnano'),
    nodemon = require('gulp-nodemon'),
    jshint = require('gulp-jshint'),
    rename = require('gulp-rename');


gulp.task('sass',function () {
    return gulp.src('app/sass/**/*.sass') // получаем источники с помощью gulp.src (Получаем все файлы с окончанием .sass в папке app/sass и дочерних директориях)
      .pipe(sass())  // используем gulp-sass (Конвертируем Sass в CSS с помощью gulp-sass)
      .pipe(gulp.dest('app/css')) 
      .pipe(browserSync.reload({stream: true}))
}); 

gulp.task('scripts',function(){
    return gulp.src([
        'app/libs/jquery/dist/jquery.min.js',
        'app/libs/magnific-popup/dist/jquery.magnific-popup.min.js',
        ])
    .pipe(concat('libs.min.js')) //конкатенация
    .pipe(uglify())  //сжатие
    .pipe(gulp.dest('app/js'));
});

gulp.task('lint', function () {
  gulp.src('./**/*.js')
    .pipe(jshint())
})

// start our server and listen for changes
gulp.task('server', function() {
    // configure nodemon
    nodemon({
        // the script to run the app
        script: 'server.js',
        // this listens to changes in any of these files/routes and restarts the application
        watch: ["server.js", "app.js", "routes/", 'public/*', 'public/*/**'],
        ext: 'js'
        // Below i'm using es6 arrow functions but you can remove the arrow and have it a normal .on('restart', function() { // then place your stuff in here }
    }).on('restart', () => {
    gulp.src('server.js')
      // I've added notify, which displays a message on restart. Was more for me to test so you can remove this
      .pipe(notify('Running the start tasks and stuff'));
  });
});
gulp.task('css-libs',['sass'],function () {
    return gulp.src('app/css/libs.css')
    .pipe(cssnano())
    .pipe(rename({suffix:'.min'}))
    .pipe(gulp.dest('app/css'));
});


gulp.task('browser-sync',function(){
    browserSync({  //Чтобы поднять сервер в Gulp, необходимо создать задачу browserSync.
        server:{
            baseDir:'app'   //После запуска сервера нужно задать корневую папку. В нашем случае это папка ‘app’:
        },
        notify: false
    });
});
gulp.task('watch',['browser-sync','css-libs','scripts'],function() {  //метод watch, который проверяет файлы на изменения
    gulp.watch('app/sass/**/*.sass',['sass']);
    // Обновляем браузер при любых изменениях в HTML или JS
    gulp.watch('app/**/*.html',browserSync.reload);
    gulp.watch('app/js/**/*.js',browserSync.reload)
});

When I am launching npm start then it says 'cannot GET / '

This is how my project looks( paths) http://prntscr.com/j316id

I have express installed,it works with gulp but I want to launch a server,not only browser-sync ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

READ ALSO
Confirmed populated array of objects returns empty

Confirmed populated array of objects returns empty

I have a method that is returning an array of objectsIt is called inside a Promise here:

108
Error when listing issues GitHub REST API

Error when listing issues GitHub REST API

The GitHub API Documentation lists the following paths to obtain a list of issues relevant to the authenticated user:

139
Impersonate a user to read contacts using a service account

Impersonate a user to read contacts using a service account

Is it possible to impersonate a user to read their contacts? I created a Service account, enabled Domain Wide Delegation and enabled the Admin and People API's

205
Force heroku to run staging script instead of production on deploy - Node JS

Force heroku to run staging script instead of production on deploy - Node JS

I have set up a staging and production pipeline on Heroku which looks like this:

177