Ionic serve 'has no method static'


#1

Hi,

I’ve just tried getting ionic working on my work mac and it doesn’t seem to play ball. Works fine for me on my personal mac.

I’m getting the following error when trying to run ionic serve. I’m not sure how to fix it.
I’ve literally just downloaded ionic by following the instruction on the getting started page.
I can build and emulate for ios.

$ ionic serve
Running serve task…

/usr/local/lib/node_modules/ionic/lib/ionic/serve.js:86
app.use(connect.static(‘www’))
^
TypeError: Object function createServer() {
function app(req, res, next){ app.handle(req, res, next); }
merge(app, proto);
merge(app, EventEmitter.prototype);
app.route = ‘/’;
app.stack = [];
return app;
} has no method 'static’
at Object.IonicServeTask._start (/usr/local/lib/node_modules/ionic/lib/ionic/serve.js:86:25)
at Object.IonicServeTask.run (/usr/local/lib/node_modules/ionic/lib/ionic/serve.js:35:8)
at Object.Ionic.run (/usr/local/lib/node_modules/ionic/lib/ionic.js:192:13)
at Object. (/usr/local/lib/node_modules/ionic/bin/ionic:10:7)
at Module._compile (module.js:456:26)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)


#2

it seems to be a node issue.
can you check which “connect” version is installed? (package.json)

or did you forget to run npm install before?


#3

Hi bengtler,

Thanks for the reply. Yes I did run the npm install. (I just ran it again to check), but I get the same error.
Do you mean the package.json within the app folder?
If so
{
“name”: “ionic-project”,
“version”: “1.0.0”,
“description”: “An Ionic project”,
“dependencies”: {
“gulp”: “^3.5.6”,
“gulp-sass”: “^0.7.1”,
“gulp-concat”: “^2.2.0”,
“gulp-minify-css”: “^0.3.0”,
“gulp-rename”: “^1.2.0”
},
“devDependencies”: {
“bower”: “^1.3.3”,
“gulp-util”: “^2.2.14”,
“shelljs”: “^0.3.0”
}
}

Cheers


#4

hey i ment this package.json:


This should be the default one.

Take a look in your ionic folder -> node_modules -> connect if it is installed.


#5

Thats the packages.json in the root of my project that I installed via the ‘ionic start myapp’ command.

In the node_modules i have no ‘connect’

I have:

  • Bower
  • gulp
  • gulp-concat
  • gulp-minify-css
  • gulp-rename
  • gulp-sass
  • gulp-util
  • shelljs

#6

then i think… went something wrong… because look at the github repository… and the ionic nodejs app needs connect to create the server correctly.

Maybe you should remove your ionic and install it step by step again
http://learn.ionicframework.com/videos/windows-android/


#7

Tried uninstalling iconic and cordova. Using
$ sudo npm cache clear
$ sudo npm uninstall ionic
$ sudo npm install ionic -g
But still get the same error :frowning:


#8

Ok so i tried updating node and that seems to have fixed this. But broken ionic emulate ios. What fun!!


#9

Just installed ionic for the first time today via npm and I have the exact same problem.

/usr/local/share/npm/lib/node_modules/ionic/lib/ionic/serve.js:86
  app.use(connect.static('www'))
                        ^
TypeError: Object function createServer() {
  function app(req, res, next){ app.handle(req, res, next); }
  merge(app, proto);
  merge(app, EventEmitter.prototype);
  app.route = '/';
  app.stack = [];
  return app;
} has no method 'static'
    at Object.IonicServeTask._start (/usr/local/share/npm/lib/node_modules/ionic/lib/ionic/serve.js:86:25)
    at Object.IonicServeTask.run (/usr/local/share/npm/lib/node_modules/ionic/lib/ionic/serve.js:28:8)
    at Object.Ionic.run (/usr/local/share/npm/lib/node_modules/ionic/lib/ionic.js:337:13)
    at Object.<anonymous> (/usr/local/share/npm/lib/node_modules/ionic/bin/ionic:10:7)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)

Edit: sudo ionic serve does work.