Ionic-cli: ionic serve gives ERRor

Created on 10 Feb 2017  路  9Comments  路  Source: ionic-team/ionic-cli

_From @onurburc on February 10, 2017 11:28_

Ionic version: (check one with "x")
[ ] 1.x
[x] 2.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
I updated the node and got the latest ionic version; when I use "ionic serve" I got an error
Here is the error that I see from the terminal

> Funbors@ ionic:serve /Users/burc/Funbors
> ionic-app-scripts serve "--v2" "--lab" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"

module.js:472
    throw err;
    ^

Error: Cannot find module 'reflect-metadata'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/burc/Funbors/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "ionic:serve" "--" "--v2" "--lab" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! Funbors@ ionic:serve: `ionic-app-scripts serve "--v2" "--lab" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the Funbors@ ionic:serve script 'ionic-app-scripts serve "--v2" "--lab" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the Funbors package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ionic-app-scripts serve "--v2" "--lab" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs Funbors
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls Funbors
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/burc/Funbors/npm-debug.log
There was an error serving your Ionic application: There was an error with the spawned command: serve

Other information:
Here is the package.json

{
  "name": "Funbors",
  "author": "Funbors",
  "homepage": "http://funbors.com",
  "private": true,
  "scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/storage": "1.1.7",
    "@types/googlemaps": "3.25.36",
    "@types/jasmine": "2.5.38",
    "angularfire2": "2.0.0-beta.6",
    "firebase": "3.6.4",
    "ionic-angular": "2.0.0",
    "ionic-app-lib": "^2.2.0",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "rxjs": "5.0.0-beta.12",
    "sw-toolbox": "^3.4.0",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.0.0",
    "typescript": "2.0.6"
  },
  "cordovaPlugins": [
    "cordova-plugin-device",
    "cordova-plugin-console",
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [
    "ios",
    {
      "platform": "ios",
      "version": "",
      "locator": "ios"
    }
  ],
  "description": "Funbors: An Ionic project"
}

Ionic info:

Your system information:

Cordova CLI: 6.3.1 
Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 1.0.0
ios-deploy version: 1.9.1 
ios-sim version: 5.0.8 
OS: macOS Sierra
Node Version: v7.4.0
Xcode version: Xcode 8.2.1 Build version 8C1002

_Copied from original issue: driftyco/ionic#10389_

Most helpful comment

MY SOLUTION !!! -> Some of the node-modules was missing in my case. Even if I do not have a version issue, I still encountered that ERROR. In order to solve that I installed the reflect-metadata module with command and it worked. So just hit from the terminal when you are inside the project:

npm i reflect-metadata

If still some modules are missing, you can install them the same way..

npm i "missing module"

All 9 comments

_From @graphefruit on February 10, 2017 13:19_

Update your nodejs to version 6.X and try it again please, 7.X isn't supported actually.
So NPM = 3.9.X not 4.X

It did not work. I get the same error from the terminal. Here is what I did:

sudo npm cache clean -f
sudo npm install -g n
sudo n 6.2.2  

After this update, here is again my ionic info:

Your system information:

Cordova CLI: 6.5.0 
Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: 1.9.1 
ios-sim version: 5.0.8 
OS: macOS Sierra
Node Version: v6.2.2
Xcode version: Xcode 8.2.1 Build version 8C1002

node -v -> v6.2.2
npm -v -> 3.9.5

screenshot_20170212-152648_1
Also when I hit ionic serve, this warning comes on the screen and it gets lost immediately after the error comes on the terminal.

Same error here! But, after downgrade for:

Your system information:

Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v6.9.5
Xcode version: Not installed

npm version: 4.2.0

and re-run: ionic start --v2 myApp tabs

works for me.

MY SOLUTION !!! -> Some of the node-modules was missing in my case. Even if I do not have a version issue, I still encountered that ERROR. In order to solve that I installed the reflect-metadata module with command and it worked. So just hit from the terminal when you are inside the project:

npm i reflect-metadata

If still some modules are missing, you can install them the same way..

npm i "missing module"

I have an existing project, updated ionic to v2.2.1 & Cordova v6.5.0. then I run ionic serve --lab gives below error. earlier, before updating it was fine.
Please give solutions.
error

Its solved updated node.js to version 6.9 to 6.10.0

Thanx @onurburc It worked for me.

Generators are only available for Ionic 2 projects (CLI v2.2.1)

Your system information:

ordova CLI: 7.0.1
Ionic Framework Version: 3.2.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.3.7
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.10.3
Xcode version: Not installed

Was this page helpful?
0 / 5 - 0 ratings