angularjs - Getting a 404 on angular.js on a MEAN app using gulp -
i attempting setup new mean app using gulp , bower keep getting 404 errors on bower dependencies when start app. used express-generator folder structure, wanted use gulp inject frontend dependencies bower , javascript files index file.
folder structure:
. +-- bin | +-- www +-- lib (bower_components) | +-- angular | +-- angular-ui-router +-- node_modules | +-- ... +-- public | +-- javascripts | | +-- angularapp.js +-- routes | +-- index.js | +-- users.js +-- views | +-- index.ejs +-- app.js +-- gulpfile.js +-- bower.json +-- package.json
and gulpfile:
'use strict'; var gulp = require('gulp'), browsersync = require('browser-sync'), inject = require('gulp-inject'), nodemon = require('gulp-nodemon'), wiredep = require('wiredep').stream, reload = browsersync.reload; var paths = { scripts: ['public/javascripts/**/*.js'] }; var nodemonoptions = { script: 'bin/www', ext: 'js', env: { 'node_env': 'development' }, verbose: false, ignore: [], watch: ['bin/*', 'routes/*', 'app.js'] }; gulp.task('inject', function(){ return gulp.src('./views/index.ejs') .pipe(inject(gulp.src(paths.scripts, {read:false}))) .pipe(gulp.dest('./views')); }); gulp.task('wiredep', function(){ gulp.src('./views/index.ejs') .pipe(wiredep({ directory: './lib', bowerjson: require('./bower.json') })) .pipe(gulp.dest('./views/')); }); gulp.task('start', function(){ nodemon({ script: 'bin/www', ext: 'js', env: { 'node_env': 'development' }, verbose: false, ignore: [], watch: ['bin/*', 'routes/*', 'app.js'] }) .on('restart'); }); gulp.task('default', ['inject', 'wiredep', 'start'], function(){ gulp.watch(paths.scripts, ['inject', reload]); });
i know gulpfile injecting angular, angular-ui-router, , angularapp.js index.ejs file, show as:
<script src="../lib/angular/angular.js"></script> <script src="../lib/angular-ui-router/release/angular-ui-router.js"></script> <script src="/public/javascripts/angularapp.js"></script>
but when start app, nothing shows on localhost:3000 , instead there 3 errors in console giving me 404 errors on localhost:3000/lib/angular/angular.js , on other 2 files.
apologies if isn't formatted correctly or if haven't provided enough information, let me know if need provide more code/info.
i haven't used express-generator, in app.js
server code, telling express serve files located in lib? try like:
app.use('/lib', express.static(process.cwd() + '/lib'));
Comments
Post a Comment