Ionic command not work


#1

I execute command ionic and the output is:

undefined:0

SyntaxError: Unexpected end of input
    at Object.parse (native)
    at Object.module.exports.load (/usr/local/lib/node_modules/ionic/lib/ionic/config.js:12:24)
    at Object.<anonymous> (/usr/local/lib/node_modules/ionic/lib/ionic/stats.js:517:31)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/ionic/lib/ionic/info.js:8:18)

In config.js the error is in:

this.data = JSON.parse(fs.readFileSync(path.join(home, this.file)));

The file that is parse to JSON is .ionic/ionic.config but readFileSync return string with this structure:

{ Stats: [Function],
  F_OK: 0,
  R_OK: 4,
  W_OK: 2,
  X_OK: 1,
  access: [Function],
  accessSync: [Function],
  exists: [Function],
  existsSync: [Function],
  readFile: [Function],
  readFileSync: [Function],
  close: [Function],
  closeSync: [Function],
  open: [Function],
  openSync: [Function],
  read: [Function],
  readSync: [Function],
  write: [Function],
  writeSync: [Function],
  rename: [Function],
  renameSync: [Function],
  truncate: [Function],
  truncateSync: [Function],
  ftruncate: [Function],
  ftruncateSync: [Function],
  rmdir: [Function],
  rmdirSync: [Function],
  fdatasync: [Function],
  fdatasyncSync: [Function],
  fsync: [Function],
  fsyncSync: [Function],
  mkdir: [Function],
  mkdirSync: [Function],
  readdir: [Function],
  readdirSync: [Function],
  fstat: [Function],
  lstat: [Function],
  stat: [Function],
  fstatSync: [Function],
  lstatSync: [Function],
  statSync: [Function],
  readlink: [Function],
  readlinkSync: [Function],
  symlink: [Function],
  symlinkSync: [Function],
  link: [Function],
  linkSync: [Function],
  unlink: [Function],
  unlinkSync: [Function],
  fchmod: [Function],
  fchmodSync: [Function],
  chmod: [Function],
  chmodSync: [Function],
  fchown: [Function],
  fchownSync: [Function],
  chown: [Function],
  chownSync: [Function],
  _toUnixTimestamp: [Function: toUnixTimestamp],
  utimes: [Function],
  utimesSync: [Function],
  futimes: [Function],
  futimesSync: [Function],
  writeFile: [Function],
  writeFileSync: [Function],
  appendFile: [Function],
  appendFileSync: [Function],
  watch: [Function],
  watchFile: [Function],
  unwatchFile: [Function],
  realpathSync: [Function: realpathSync],
  realpath: [Function: realpath],
  createReadStream: [Function],
  ReadStream: 
   { [Function: ReadStream]
     super_: 
      { [Function: Readable]
        ReadableState: [Function: ReadableState],
        super_: [Object],
        _fromList: [Function: fromList] } },
  FileReadStream: 
   { [Function: ReadStream]
     super_: 
      { [Function: Readable]
        ReadableState: [Function: ReadableState],
        super_: [Object],
        _fromList: [Function: fromList] } },
  createWriteStream: [Function],
  WriteStream: 
   { [Function: WriteStream]
     super_: { [Function: Writable] WritableState: [Function: WritableState], super_: [Object] } },
  FileWriteStream: 
   { [Function: WriteStream]
     super_: { [Function: Writable] WritableState: [Function: WritableState], super_: [Object] } },
  SyncWriteStream: 
   { [Function: SyncWriteStream]
     super_: 
      { [Function: Stream]
        super_: [Object],
        Readable: [Object],
        Writable: [Object],
        Duplex: [Object],
        Transform: [Object],
        PassThrough: [Object],
        Stream: [Circular] } } }

JSON.parse generate error because string is bad formed:
Stats ==> "Stats"

I run the command on Ubuntu 14.04. I installed ionic with sudo apt-get install npm and sudo npm install -g ionic

Any solution?


#2

have you install the cordova?


#3

Not sure about ubuntu, and how they manage packages, but you’ll also need node, not just npm.


#4

Hi,

Did you fix this issue?

I am having the same problem on Mac


#5

I’m having the same issue on Mac.


#6

Found the fix! It’s an error in /usr/local/lib/node_modules/ionic-app-lib/lib/config.js

You’ll want to edit the file, .eg:

sudo nano /usr/local/lib/node_modules/ionic-app-lib/lib/config.js

And change line 7:

CONFIG_FILE: '.ionic/ionic.config',

To have a slash after the dot:

CONFIG_FILE: './ionic/ionic.config',

Then save the file, and try running an ionic command:

ionic

Ionic is [undefined:0] and won't run