I get syntaxError when ionic upload


#1

I need a help .

I get this error message when trying to upload the app to Ionic View

SyntaxError: Unexpected token <
    at Object.parse (native)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/upload.js:292:25)
    at IncomingMessage.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11)

Unexpected token < (CLI v1.6.4)

Your system information:

Cordova CLI: 5.1.1
Ionic Version: 1.0.1
Ionic CLI Version: 1.6.4
Ionic App Lib Version: 0.3.8
ios-deploy version: Not installed
ios-sim version: 3.1.1 
OS: Mac OS X Yosemite
Node Version: v0.12.7
Xcode version: Xcode 6.3.1 Build version 6D1002 

This started to happen when I added $cordovaImagePicker

var options = {
    maximumImagesCount: 1
};
$ionicPlatform.ready(function() {
    $cordovaImagePicker.getPictures(options)
    .then(function (results) {
        for (var i = 0; i < results.length; i++) {
            console.log('Image URI: ' + results[i]);
        }
    }, function(error) {
      // error getting photos
    });
});

Please help me.

Thank you


#2

Look at this file at line 292 as indicated, you’ll see that it failed to parse the JSON data in response sent by server.

    jsonData = JSON.parse(data);

So it has nothing to do with your app code.

If you can reproduce it easily, modify this file and log the data received and report it to Ionic support.


#3

Same issue here… I can not upload to ionic.io or set push environment… It happens today.


#4

My solution was to delete the app_id on app_id


#5

Did you upgrade npm recently? I ran into this issue when I upgraded npm to v_2.14.7 (as part of an upgrade to node.js v4.2.0). I downgraded npm to the version that last worked for me: v_2.14.2

npm install -g npm@2.14.2

Everything back to normal when I ionic upload now.