Node server setup shows error "can not find module"

i installed node and npm with brew and also installed npm install -g appium but node server not running with appium

please help me i am stuck in it since two days

Hi @pushpank

Are you behind any company proxy or firewall, if yes then you need to configure proxy first and then install.

Hope this will help.

Regards
Ravi

Hello Ravi,

We are not using any proxy or firewall, it may be node install issue but i can not identify

But in /Applications/Appium.app/Contents/Resources/node_modules/appium/bin> i found only one file > ios-webkit-debug-proxy-launcher.js

may its breaking it ?

Please suggest me further

If npm succesfully installed appium globally, you can launch appium by typing “appium” in your command line. But i see some NPM errors, so i assume it didn’t. What happens when you directly type “appium” in your console ?

To check whether node and npm is working or not try below commands:

Node -v --> This will give you node version
npm -v --> This will give you npm version

Then try below command to install appium:

npm install -g appium

to install specific version use

npm install -g appium@version no

Tip : try giving some invalid version, if you are getting version error it means npm is hitting to appium server and version is being verified.

Let me know if this helps.

Regards
Ravi

Hello sam,

I already run npm install -g appium and its run successful but when i type appium in console then its shows bash: appium: command not found

Hello Ravi,
node version-4.4.5
npm version- 2.15.5

installed appium globally its shows some error

srikantas-Mac-mini-3:~ RajShekhar_DiroLabs$ node -v
v4.4.5
srikantas-Mac-mini-3:~ RajShekhar_DiroLabs$ npm -v
2.15.5
srikantas-Mac-mini-3:~ RajShekhar_DiroLabs$ npm install -g [email protected]
npm WARN peerDependencies The peer dependency continuation-local-storage@~3 included from cls-bluebird will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency bluebird@>=1.0.3 included from cls-bluebird will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.

[email protected] install /Users/RajShekhar_DiroLabs/npm/lib/node_modules/appium/node_modules/appium-selendroid-driver
node ./bin/install.js

Error: Cannot find module ‘core-js/library/fn/is-iterable’
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/Users/RajShekhar_DiroLabs/npm/lib/node_modules/appium/node_modules/asyncbox/node_modules/babel-runtime/core-js/is-iterable.js:1:31)
at Module._compile (module.js:409:26)
at Object.Module._extensions…js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)

[email protected] install /Users/RajShekhar_DiroLabs/npm/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver
node install-npm.js

Error trying to install Chromedriver binary. Waiting and trying again. Cannot find module ‘core-js/library/fn/get-iterator’
Error trying to install Chromedriver binary. Waiting and trying again. Cannot find module ‘core-js/library/fn/get-iterator’
Error trying to install Chromedriver binary. Waiting and trying again. Cannot find module ‘core-js/library/fn/get-iterator’
Error trying to install Chromedriver binary. Waiting and trying again. Cannot find module ‘core-js/library/fn/get-iterator’
Error trying to install Chromedriver binary. Waiting and trying again. Cannot find module ‘core-js/library/fn/get-iterator’
Error trying to install Chromedriver binary. Waiting and trying again. Cannot find module ‘core-js/library/fn/get-iterator’
Error trying to install Chromedriver binary. Waiting and trying again. Cannot find module ‘core-js/library/fn/get-iterator’
Error trying to install Chromedriver binary. Waiting and trying again. Cannot find module ‘…/modules/web.dom.iterable’
Error trying to install Chromedriver binary. Waiting and trying again. Cannot find module ‘…/modules/web.dom.iterable’
Error trying to install Chromedriver binary. Waiting and trying again. Cannot find module ‘…/modules/web.dom.iterable’
info Chromedriver Install Installing Chromedriver version ‘2.21’ for platform ‘mac’ and architecture ‘32’
info Chromedriver Install Opening temp file to write chromedriver_mac32 to…
info Chromedriver Install Downloading http://chromedriver.storage.googleapis.com/2.21/chromedriver_mac32.zip
info Chromedriver Install Writing binary content to /var/folders/ys/m78mnsws5ds1g73hdw694k3w0000gn/T/201653-6672-t1jg8z/chromedriver_mac32.zip…
info Chromedriver Install Extracting /var/folders/ys/m78mnsws5ds1g73hdw694k3w0000gn/T/201653-6672-t1jg8z/chromedriver_mac32.zip to /var/folders/ys/m78mnsws5ds1g73hdw694k3w0000gn/T/201653-6672-t1jg8z/chromedriver_mac32
info Chromedriver Install Creating /Users/RajShekhar_DiroLabs/npm/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac…
info Chromedriver Install Copying unzipped binary, reading from /var/folders/ys/m78mnsws5ds1g73hdw694k3w0000gn/T/201653-6672-t1jg8z/chromedriver_mac32/chromedriver…
info Chromedriver Install Writing to /Users/RajShekhar_DiroLabs/npm/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver…
info Chromedriver Install /Users/RajShekhar_DiroLabs/npm/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-chromedriver/chromedriver/mac/chromedriver successfully put in place
npm ERR! Darwin 15.2.0
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “install” “-g” “[email protected]
npm ERR! node v4.4.5
npm ERR! npm v2.15.5
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node ./bin/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script ‘node ./bin/install.js’.
npm ERR! This is most likely a problem with the appium-selendroid-driver package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs appium-selendroid-driver
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR!
npm ERR! npm owner ls appium-selendroid-driver
npm ERR! There is likely additional logging output above.

@ravikr42 It appears to me that you’re not calling “node appium” in the correct directory, can you try this?

cd /Applications/Appium.app/Contents/Resources/node_modules/
node appium

Or
cd /Applications/Appium.app/Contents/Resources/node_modules/appium
node .

@sam
Its showing appium version but still not working for me shows arror as previous
srikantas-Mac-mini-3:node_modules RajShekhar_DiroLabs$ node appium
[Appium] Welcome to Appium v1.5.2
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

What errors are you talking about? Because as i see in the last logs you provided, Appium server started
And when do they occure?

Its Showing error
@sam_viz
srikantas-Mac-mini-3:appium RajShekhar_DiroLabs$ node appium --nodeconfig /Users/RajShekhar_DiroLabs/Desktop/node1.json -p 4730
module.js:327
throw err;
^

Error: Cannot find module ‘/Applications/Appium.app/Contents/Resources/node_modules/appium/appium’
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)

But with node_modules path it shows
srikantas-Mac-mini-3:node_modules RajShekhar_DiroLabs$ node appium --nodeconfig /Users/RajShekhar_DiroLabs/Desktop/node1.json -p 4730
[Appium] Welcome to Appium v1.5.2
[Appium] Non-default server args:
[Appium] port: 4730
[Appium] nodeconfig: ‘/Users/RajShekhar_DiroLabs/Desktop/node1.json’
[Appium] Unable to load node configuration file to register with grid: ENOENT: no such file or directory, open ‘/Users/RajShekhar_DiroLabs/Desktop/node1.json’
[Appium] Appium REST http interface listener started on 0.0.0.0:4730
^C

and with appium its showing not found
srikantas-Mac-mini-3:~ RajShekhar_DiroLabs$ appium
-bash: appium: command not found
srikantas-Mac-mini-3:~ RajShekhar_DiroLabs$ appium -v
-bash: appium: command not found

what i am doing wrong , please suggest me

Also when i running appium server from terminal it shows
srikantas-Mac-mini-3:~ RajShekhar_DiroLabs$ appium &
[1] 1662
-bash: appium: command not found
[1]+ Exit 127 appium

Hello thanks for response , mine this is resolve by re change path of npm .
But now i am facing the issue in start node server with selenium grid, Selenium grid is running but when i start node server with json file “node appium --nodeconfig /Users/RajShekhar_DiroLabs/Desktop/node1.json -p 4730”
it shows me logs like
Appium] Welcome to Appium v1.5.2
[Appium] Non-default server args:
[Appium] port: 4730
[Appium] nodeconfig: ‘/Users/RajShekhar_DiroLabs/Desktop/node1.json’
[Appium] Unable to load node configuration file to register with grid: ENOENT: no such file or directory, open ‘/Users/RajShekhar_DiroLabs/Desktop/node1.json’
[Appium] Appium REST http interface listener started on 0.0.0.0:4730

json file
{ “capabilities”: [ { “browserName”: “Android”, “version”:“5.0.1”, “maxInstances”: 3, “platform”:“ANDROID”, “deviceName”:“FCAZGU007688H3D” } ], “configuration”: {
“nodeTimeout”:120, “port”:4730, “hubPort”:4444, “proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”, “url”:“http://127.0.0.1:4730/wd/hub”, “hub”: “127.0.0.1:4444/grid/register”, “hubHost”:“127.0.0.1”, “nodePolling”:2000, “registerCycle”:10000, “register”:true, “cleanUpCycle”:2000, “timeout”:30000, “maxSession”:1
} }

node is running but not on selenium grid can please suggest me in this case

The error means that the server didn’t find the file named “node1.json” in you desktop folder. Can you confirm that you’re specifying the right path and file name?

P.S: before you launch appium node, make sure you launch selenium hub on the correct url 127.0.0.1:4444/grid/register

Thanks @sam for reply, its resolved now my mac is added some unicode in json.
Now two node server are running but my script are running only in one node do not why, can you suggest me in this

Use the applicationName capability in your node.json.
Refer: http://www.vimalselvam.com/2016/05/15/selenium-grid-for-appium-mobile-automation/

Still with applicationName caps script is working only in one node

{

"capabilities": [{
		"applicationName": "5.0.2Android",
		"browserName": "5.0.2Android",
		"version": "5.0.2",
		"maxInstance": 1,
		"platform": "ANDROID"


	}

],

"configuration":

{

	"nodeTimeout": 120,

	"port": 4725,

	"hubPort": 4444,

	"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",

	"hubHost": "10.2.10.45",
	"host": "127.0 .0 .1",
	"role": "node",

	"nodePolling": 2000,

	"register": true,

	"registerCycle": 1000,

	"cleanUpCycle": 2000,

	"timeout": 30000,

	"masSession": 1

}

}

Could you please post both of your node json and both capabilities from your test script?

node-1

{

"capabilities": [{
		"applicationName": "Asus",
		"browserName": "Asus",
		
		"maxInstance": 1,
		"platform": "ANDROID"


	}

],

"configuration":

{

	"nodeTimeout": 120,

	"port": 4725,

	"hubPort": 4444,

	"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",

	"hubHost": "10.2.10.45",
	"host": "127.0 .0 .1",
	"role": "node",

	"nodePolling": 2000,

	"register": true,

	"registerCycle": 1000,

	"cleanUpCycle": 2000,

	"timeout": 30000,

	"masSession": 1

}

}

node 2
{

"capabilities": [{
    "browserName": "Android",
    "version": "4.4.2",

    "maxInstance": 1,

    "platform": "ANDROID"

}

],

"configuration":

{

    "nodeTimeout": 120,

    "port": 4728,

    "hubPort": 4444,

    "proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy",

   "hubHost": "10.2.10.45",
    "host": "127.0 .0 .1",

    "role": "node",

    "nodePolling": 2000,

    "register": true,

    "registerCycle": 1000,

    "cleanUpCycle": 2000,

    "timeout": 30000,

    "masSession": 1

}

}

capabilities
public static RemoteWebDriver LunchApplication() throws Exception {

	try{
	
File app = new File ("/Users/RajShekhar_DiroLabs/Desktop/Appium/dirAlpha-debug.apk");
	DesiredCapabilities capabilities =  new DesiredCapabilities();
	capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
	capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Android");
	capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
      RemoteWebDriver driver = new RemoteWebDriver(new URL("http://10.2.10.45:4444/wd/hub") , capabilities);

its running on only one node randomly