Node appium command fails with "SyntaxError: Unexpected reserved word" Error

I am having trouble launching the appium server from the command line. Doing so results in "Unexpected reserved word" error:

Any help would be appreciated, thanks!

Which version of appium are you running?

I think node figures out which script file to run by checking what the “main” and “bin” values are in package.json. Double check your package.json. On branch master of Appium’s git project , these values are:

"main": "./build/lib/main.js",
"bin": {
  "appium": "./build/lib/main.js",
  "authorize-ios": "./node_modules/.bin/authorize-ios"

Thanks, afwang, these are the values I found in package.json:

Which version of node are you using?

I’m using version 4.2.6

You’re running from source, right? If you’re on the latest version of Appium, did you remember to run node install inside the project directory (for versions older than 1.5, did you remember to run the script)?

I’m not entirely sure, I installed node, appium, and all of the dependencies that I would need to automate and test android apps.

I was simply trying to start the appium server within the bin folder where appium.js is located.

You mean install node within the Appium directory? I may not have done that.

I don’t think I did this part, either. Does need any parameters? And where do I need to run it from?

If you got Appium using git, then you’re running from source. If you used “npm install appium”, you’re not running Appium from source.

Once you know whether you’re running from source or not, you can determine if you need to follow the steps below:

  1. If you are running from source, figure out which branch/tag/commit you’re running on with git branch. Appium versions are always tagged. The master branch should be treated as the “latest” version of Appium (AKA 1.5.2+). If you’re running at least version 1.5, be sure to run node install in the project containing Appium.
  2. If you are not running Appium from source, you do not need to do anything, but please post here so the community knows what your situation is exactly.

Ah, Ok, that makes sense. I am not running from source. I installed everything directly using npm.

Okay. In the directory where you ran npm install appium, there should be a subdirectory called “node_modules”. Inside that directory is a hidden directory called “.bin”. Inside .bin is a link to the Appium executable, and it should be just called “appium”. Try running node_modules/.bin/appium instead.

The file that this appium link points to a is a transpiled version of lib/main.js. Javascript transpilation means to take new features of Javascript and convert them into pieces of code that will work on older versions of Javascript (“import” is a relatively new feature that needs to be transpiled).

Ok, I tried that a few times, it doesn’t look like the appium link file is in that hidden .bin folder. Is there a way to transpile the main appium.js file?

You’d have to include the babel transpiler and then invoke that to transpile Appium, but the package that’s installed through npm has already been transpiled. Do you remember if there were any errors that popped up during Appium’s installation?

There were a number of errors that came up, dealing with folder permissions I believe.

Do you mind re-installing Appium? Since you’re installing to system directories, make sure you have the proper permissions to install to those directories (e.g. if you need to run the install as a superuser, then you should run it as a superuser).

I don’t mind, the process just seems clunky (I’m still new to using the weird directory structures in MAC OS).

Just as an FYI, I was able to fix this issue by uninstalling and reinstalling everything (npm, node, and appium).

This article helped:

1 Like