39712

Gulp with “NPM start” causes a blank page with the text: Cannot GET / when testing Locally

Question:

I've been following this tutorial <a href="https://josee.me/2016/03/30/angular2-electron-yeoman-sass-bootstrap-a-complete-guide-to-setting-up-a-new-desktop-app/" rel="nofollow">Angular2, Bootstrap, Yeoman, Gulp, tutorial</a> and I get up to the frontend task section, but then something happens when I try to test the code locally.

Whenever I use <strong>npm start</strong> I run the following code, but end up getting the blank webpage with <strong>Cannot GET/</strong> <a href="https://i.stack.imgur.com/ni6bJ.jpg" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/ni6bJ.jpg" data-original="https://i.stack.imgur.com/ni6bJ.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

Folder Structure:

> my-vzlr > -build > -node_modules > -src > --app > ---app.js > ---index.html > ---main.js > --electron > --fonts > --images > --styles > -gulpfile.js > -package.json

<strong>Package.json:</strong>

> { "name": "my-vzlr", "version": "0.0.0", "private": true, > "scripts": { > "start": "gulp clean && gulp frontend && gulp dev", > "build": "gulp clean && gulp frontend" }, "dependencies": { > "angular2": "2.0.0-beta.2", > "traceur": "0.0.102", > "es6-promise": "^3.0.2", > "es6-shim": "^0.33.3", > "rxjs": "5.0.0-beta.0", > "zone.js": "0.5.10", > "reflect-metadata": "0.1.2", > "systemjs": "0.19.6" }, "devDependencies": { > "del": "^2.2.2", > "gulp": "3.9.0", > "gulp-rename": "1.2.2", > "gulp-symdest": "^1.0.0", > "gulp-traceur": "0.17.2", > "gulp-webserver": "0.9.1" } }

<strong>Gulpfile.JS</strong>

var gulp = require('gulp'), del = require('del'), rename = require('gulp-rename'), traceur = require('gulp-traceur'), webserver = require('gulp-webserver'), symdest = require('gulp-symdest'); var config = { sourceDir: 'src', buildDir: 'build', packagesDir: 'packages', npmDir: 'node_modules' }; gulp.task('clean', function() { return del(config.buildDir + '/**/*', { force: true }); }); // run init tasks //gulp.task('default', ['dependencies', 'js', 'html', 'css']); // run development task gulp.task('dev', ['dev:watch', 'dev:serve']); // serve the build dir gulp.task('dev:serve', function () { gulp.src(config.buildDir) .pipe(webserver({ open: true })); }); // watch for changes and run the relevant task gulp.task('dev:watch', function() { gulp.watch(config.sourceDir + '/**/*.js', ['frontend:js']); gulp.watch(config.sourceDir + '/**/*.html', ['frontend:html']); gulp.watch(config.sourceDir + '/**/*.css', ['frontend:css']); }); gulp.task('frontend', [ 'frontend:dependencies', 'frontend:js', 'frontend:html', 'frontend:css' ]); // move dependencies into build dir gulp.task('frontend:dependencies', function() { return gulp.src([ config.npmDir + '/traceur/bin/traceur-runtime.js', config.npmDir + '/systemjs/dist/system-csp-production.src.js', config.npmDir + '/systemjs/dist/system.js', config.npmDir + '/reflect-metadata/Reflect.js', config.npmDir + '/angular2/bundles/angular2.js', config.npmDir + '/angular2/bundles/angular2-polyfills.js', config.npmDir + '/rxjs/bundles/Rx.js', config.npmDir + '/angular2/bundles/router.js', config.npmDir + '/es6-shim/es6-shim.min.js', config.npmDir + '/es6-shim/es6-shim.map' ]) .pipe(gulp.dest(config.buildDir + '/lib')); }); // transpile & move js gulp.task('frontend:js', function() { return gulp.src( config.sourceDir + '/**/*.js') .pipe(rename({ extname: '' })) .pipe(traceur({ modules: 'instantiate', moduleName: true, annotations: true, types: true, memberVariables: true })) .pipe(rename({ extname: '.js' })) .pipe(gulp.dest(config.buildDir)); }); // move html gulp.task('frontend:html', function() { return gulp.src(config.sourceDir + '/**/*.html') .pipe(gulp.dest(config.buildDir)) }); // move css gulp.task('frontend:css', function() { return gulp.src(config.sourceDir + '/**/*.css') .pipe(gulp.dest(config.buildDir)) });

Answer1:

So the short of it is to make sure the app is structured so Gulp can move all the files it needs to

Recommend

  • Gulp copy single file (src pipe dest) with wildcarded directory
  • ERROR in Metadata version mismatch for module
  • How to make an Ionic content scroll
  • Upgrade from Jenkins Weekly to LTS
  • LDA: Why sampling for inference of a new document?
  • Manage different base layouts in Angular2
  • Exactly what should happen in a CALayer's display/drawRect methods?
  • What are zone turns?
  • How to get to older Xcode beta version?
  • twisted.internet.error.ConnectError when run scrapy spider
  • Is there a equivalent to JSON.Net in Java? [duplicate]
  • jQueryMobile, Ajax Navigation, and MVC
  • How to load Q library with Require.js?
  • end daemon processes with multiprocessing module
  • Unzip archive in .Net CORE 1.0
  • How can I replace the server in Web Component Tester
  • C# fibonacci function returning errors
  • perl, mysql - fasting way to upload a csv file into mysql?
  • Angular2 component view does not update on value change via method
  • How to get current document uri in XSLT?
  • Convert Type Decimal to Hex (string) in .NET 3.5
  • What is the purpose of TaskExecutor in spring?
  • Unable to install Git-core+svn by MacPorts
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Installing iPhone App to iPhone
  • print() is showing quotation marks in results
  • Play WS (2.2.1): post/put large request
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • Different response to non-authenticated users and AJAX calls
  • Deserializing XML into class C#
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Circular dependency while pushing http interceptor
  • Arrays break string types in Julia
  • Linker errors when using intrinsic function via function pointer
  • How to include full .NET prerequisite for Wix Burn installer
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Is it possible to post an object from jquery to bottle.py?
  • costura.fody for a dll that references another dll
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize