Issue deploying node.js with apigeetool - compilation error - illegal character

Not applicable

I am trying to deploy my node application (which runs locally) using apigeetool. I have successfully deployed one in the past and am using there current command:

apigeetool deploynodeapp -n my_node -d . -m server.js -o actual_organization -e test -b / -u actual_username -p actual_password

However, when I do this, I get the following error:

Error: Error: Error uploading resource server.js: 500
{
  "message" : "com.apigee.rest.framework.ValidationException{ code = scripts.node.CompilationFailure, message = Compilation error: server.js:1 illegal character, associated contexts = []}",
  "contexts" : [ ],
  "cause" : {
    "code" : "scripts.node.CompilationFailure",
    "message" : "Compilation error: server.js:1 illegal character",
    "contexts" : [ ]
  }
}

Thought there was some issue with the compiling of my code, so I compiled it using google's compiler and had no problems (there were no errors or warnings, just returned success).

Does anyone know what is happening? Running my server.js locally does work

thanks!

Solved Solved
0 3 670
1 ACCEPTED SOLUTION

Not applicable

So i figured it out - You must remove the line:

#!/usr/bin/env node

Which is autogenerated by the generator - It no longer gives that error - I was mistaken as I thought the error on line 1 was an example of the error message not giving the correct line number.... Lesson learned.

View solution in original post

3 REPLIES 3

Not applicable

Hi Kevin, if possible, can you please post the server.js file? I can try it from my laptop. Also, did you try apigeetool from NPM or the Python one? If you haven't tried apigeetool from NPM, please give it a try. Maybe that's all it takes to fix your issue.

Not applicable

Thanks @dzuluaga - Below is the code. Admittedly I used express generator

#!/usr/bin/env node


/**
 * Module dependencies.
 */


var app = require('./app');
var debug = require('debug')('myApp:server');
var http = require('http');
var https = require('https');


/**
 * Get port from environment and store in Express.
 */


var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);


/**
 * Create HTTP server.
 */


var server = http.createServer(app);


/**
 * Listen on provided port, on all network interfaces.
 */


server.listen(port);
server.on('error', onError);
server.on('listening', onListening);


/**
 * Normalize a port into a number, string, or false.
 */


function normalizePort(val) {
  var port = parseInt(val, 10);


  if (isNaN(port)) {
    // named pipe
    return val;
  }


  if (port >= 0) {
    // port number
    return port;
  }


  return false;
}


/**
 * Event listener for HTTP server "error" event.
 */


function onError(error) {
  if (error.syscall !== 'listen') {
    throw error;
  }


  var bind = typeof port === 'string'
    ? 'Pipe ' + port
    : 'Port ' + port


  // handle specific listen errors with friendly messages
  switch (error.code) {
    case 'EACCES':
      console.error(bind + ' requires elevated privileges');
      process.exit(1);
      break;
    case 'EADDRINUSE':
      console.error(bind + ' is already in use');
      process.exit(1);
      break;
    default:
      throw error;
  }
}


/**
 * Event listener for HTTP server "listening" event.
 */


function onListening() {
  var addr = server.address();
  var bind = typeof addr === 'string'
    ? 'pipe ' + addr
    : 'port ' + addr.port;
  debug('Listening on ' + bind);
}


Not applicable

So i figured it out - You must remove the line:

#!/usr/bin/env node

Which is autogenerated by the generator - It no longer gives that error - I was mistaken as I thought the error on line 1 was an example of the error message not giving the correct line number.... Lesson learned.