Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeing this error #224

Open
shgattu opened this issue Jun 13, 2017 · 2 comments
Open

Seeing this error #224

shgattu opened this issue Jun 13, 2017 · 2 comments

Comments

@shgattu
Copy link

shgattu commented Jun 13, 2017

Hi,
I am seeing below error when I run gulp connect.
Any help will be really appreciated.

Thanks,
Shwetha
10:38:25] Starting 'connect'...
[10:38:25] 'connect' errored after 6.57 ms
[10:38:25] TypeError: connect.static is not a function
at /rmbs/apps/node_modules/gulp-connect/index.js:158:44
at Array.forEach (native)
at ConnectApp.handlers (/apps/node_modules/gulp-connect/index.js:157:17)
at ConnectApp.run (/apps/node_modules/gulp-connect/index.js:55:10)
at new ConnectApp (/apps/node_modules/gulp-connect/index.js:50:10)
at Object.module.exports.server (/apps/node_modules/gulp-connect/index.js:219:11)

@shgattu
Copy link
Author

shgattu commented Jun 13, 2017

This is the snippet from gulpfile.js

gulp.task('connect', function() {
connect.server({
root: ['dist'],
port: 8000

});

});

@leogouveia
Copy link

leogouveia commented Oct 4, 2018

Hi, I just discovered there was breaking changes on connect version 3.6.6, so, there's no more connect.static(..).
You should use serve-static instead of connect.static().
See the documentation from connect and serve-static.
Here is an example of how I solved this problem:

const serveStatic = require('serve-static');

connect.server({
    name: '...',
    root: ['./src/cliente', './bower_components'],
    port: 3002,
    middleware: connect => 
      [
        connect().use('/bower_components', serveStatic('./bower_components')),
        connect().use('/node_modules', serveStatic('./node_modules'))
      ]
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants