Unable to install appium server using npm

Tried to install appium server using the following command:
npm install -g appium

Getting the following error:

[email protected] install /Users/username/node_modules/appium/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/bufferutil
node-gyp rebuild

CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node

[email protected] install /Users/username/node_modules/appium/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate
node-gyp rebuild

CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node

[email protected] install /Users/username/node_modules/appium/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/bufferutil
node-gyp rebuild

CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node

[email protected] install /Users/username/node_modules/appium/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws/node_modules/utf-8-validate
node-gyp rebuild

CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node

[email protected] install /Users/username/node_modules/appium/node_modules/udidetect
make

gcc -o udidetect -framework CoreFoundation -framework MobileDevice -F/System/Library/PrivateFrameworks udidetect.c

[email protected] install /Users/username/node_modules/appium/node_modules/ws/node_modules/bufferutil
node-gyp rebuild

CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
In file included from …/src/bufferutil.cc:16:
…/node_modules/nan/nan.h:261:25: error: redefinition of ‘_NanEnsureLocal’
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
…/node_modules/nan/nan.h:256:25: note: previous definition is here
NAN_INLINE v8::Local _NanEnsureLocal(v8::Handle val) {
^
…/node_modules/nan/nan.h:661:13: error: no member named ‘smalloc’ in namespace ‘node’
, node::smalloc::FreeCallback callback
^
…/node_modules/nan/nan.h:672:12: error: no matching function for call to ‘New’
return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
^
~~~~~~~~~~
/Users/username/.node-gyp/5.1.0/include/node/node_buffer.h:31:40: note: candidate function not viable: no known
conversion from ‘uint32_t’ (aka ‘unsigned int’) to ‘enum encoding’ for 3rd argument
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate,
^
/Users/username/.node-gyp/5.1.0/include/node/node_buffer.h:43:40: note: candidate function not viable: 2nd argument
('const char ') would lose const qualifier
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate
isolate,
^
/Users/username/.node-gyp/5.1.0/include/node/node_buffer.h:28:40: note: candidate function not viable: requires 2
arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate, size_t length);
^
/Users/username/.node-gyp/5.1.0/include/node/node_buffer.h:36:40: note: candidate function not viable: requires 5
arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate,
^
In file included from …/src/bufferutil.cc:16:
…/node_modules/nan/nan.h:676:12: error: no viable conversion from ‘v8::MaybeLocalv8::Object’ to
‘v8::Localv8::Object
return node::Buffer::New(v8::Isolate::GetCurrent(), size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/username/.node-gyp/5.1.0/include/node/v8.h:210:7: note: candidate constructor (the implicit copy constructor)
not viable: no known conversion from ‘v8::MaybeLocalv8::Object’ to ‘const v8::Localv8::Object &’ for 1st
argument
class Local {
^
/Users/username/.node-gyp/5.1.0/include/node/v8.h:210:7: note: candidate constructor (the implicit move constructor)
not viable: no known conversion from ‘v8::MaybeLocalv8::Object’ to ‘v8::Localv8::Object &&’ for 1st
argument
class Local {
^
/Users/username/.node-gyp/5.1.0/include/node/v8.h:214:13: note: candidate template ignored: could not match ‘Local’
against ‘MaybeLocal’
V8_INLINE Local(Local that)
^
/Users/username/.node-gyp/5.1.0/include/node/v8.h:326:13: note: candidate template ignored: could not match 'S
against ‘v8::MaybeLocalv8::Object
V8_INLINE Local(S
that)
^
In file included from …/src/bufferutil.cc:16:
…/node_modules/nan/nan.h:683:26: error: no member named ‘Use’ in namespace ‘node::Buffer’
return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
^
In file included from …/src/bufferutil.cc:7:
/Users/username/.node-gyp/5.1.0/include/node/v8.h:221:5: error: assigning to ‘v8::Primitive *volatile’ from
incompatible type ‘v8::Value *’
TYPE_CHECK(T, S);
^
~
/Users/username/.node-gyp/5.1.0/include/node/v8.h:180:37: note: expanded from macro ‘TYPE_CHECK’
(static_cast<T volatile*>(0)) = static_cast<S*>(0);
^ ~~~~~~~~~~~~~~~~~~
…/node_modules/nan/nan.h:414:12: note: in instantiation of function template specialization
‘v8::Localv8::Primitive::Localv8::Value’ requested here
return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent())));
^
…/node_modules/nan/nan.h:398:30: note: expanded from macro ‘NanEscapeScope’

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                         ^

In file included from …/src/bufferutil.cc:7:
/Users/username/.node-gyp/5.1.0/include/node/v8.h:221:5: error: assigning to 'v8::Boolean volatile’ from incompatible
type 'v8::Value
TYPE_CHECK(T, S);
^~~~~~~~~~~~~~~~
/Users/username/.node-gyp/5.1.0/include/node/v8.h:180:37: note: expanded from macro ‘TYPE_CHECK’
(static_cast<T volatile
>(0)) = static_cast<S
>(0);
^ ~~~~~~~~~~~~~~~~~~
…/node_modules/nan/nan.h:424:12: note: in instantiation of function template specialization
‘v8::Localv8::Boolean::Localv8::Value’ requested here
return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent())));
^
…/node_modules/nan/nan.h:398:30: note: expanded from macro ‘NanEscapeScope’

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                         ^

In file included from …/src/bufferutil.cc:7:
/Users/username/.node-gyp/5.1.0/include/node/v8.h:221:5: error: assigning to 'v8::Function volatile’ from
incompatible type 'v8::Value
TYPE_CHECK(T, S);
^~~~~~~~~~~~~~~~
/Users/username/.node-gyp/5.1.0/include/node/v8.h:180:37: note: expanded from macro ‘TYPE_CHECK’
(static_cast<T volatile
>(0)) = static_cast<S
>(0);
^ ~~~~~~~~~~~~~~~~~~
…/node_modules/nan/nan.h:1514:12: note: in instantiation of function template specialization
‘v8::Localv8::Function::Localv8::Value’ requested here
return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex)
^
…/node_modules/nan/nan.h:398:30: note: expanded from macro ‘NanEscapeScope’

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                         ^

In file included from …/src/bufferutil.cc:7:
/Users/username/.node-gyp/5.1.0/include/node/v8.h:221:5: error: assigning to 'v8::Object volatile’ from incompatible
type 'v8::Value
TYPE_CHECK(T, S);
^~~~~~~~~~~~~~~~
/Users/username/.node-gyp/5.1.0/include/node/v8.h:180:37: note: expanded from macro ‘TYPE_CHECK’
(static_cast<T volatile
>(0)) = static_cast<S
>(0);
^ ~~~~~~~~~~~~~~~~~~
…/node_modules/nan/nan.h:1632:12: note: in instantiation of function template specialization
‘v8::Localv8::Object::Localv8::Value’ requested here
return NanEscapeScope(handle->Get(NanNew(key)).Asv8::Object());
^
…/node_modules/nan/nan.h:398:30: note: expanded from macro ‘NanEscapeScope’

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                         ^

9 errors generated.
make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.0.0
gyp ERR! command “/usr/local/Cellar/node/5.1.0/bin/node” “/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /Users/username/node_modules/appium/node_modules/ws/node_modules/bufferutil
gyp ERR! node -v v5.1.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: node-gyp rebuild
npm WARN install:[email protected] Exit status 1

[email protected] install /Users/username/node_modules/appium/node_modules/ws/node_modules/utf-8-validate
node-gyp rebuild

CXX(target) Release/obj.target/validation/src/validation.o
In file included from …/src/validation.cc:15:
…/node_modules/nan/nan.h:261:25: error: redefinition of ‘_NanEnsureLocal’
NAN_INLINE v8::Local _NanEnsureLocal(v8::Local val) {
^
…/node_modules/nan/nan.h:256:25: note: previous definition is here
NAN_INLINE v8::Local _NanEnsureLocal(v8::Handle val) {
^
…/node_modules/nan/nan.h:661:13: error: no member named ‘smalloc’ in namespace ‘node’
, node::smalloc::FreeCallback callback
^
…/node_modules/nan/nan.h:672:12: error: no matching function for call to ‘New’
return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
^
~~~~~~~~~~
/Users/username/.node-gyp/5.1.0/include/node/node_buffer.h:31:40: note: candidate function not viable: no known
conversion from ‘uint32_t’ (aka ‘unsigned int’) to ‘enum encoding’ for 3rd argument
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate,
^
/Users/username/.node-gyp/5.1.0/include/node/node_buffer.h:43:40: note: candidate function not viable: 2nd argument
('const char ') would lose const qualifier
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate
isolate,
^
/Users/username/.node-gyp/5.1.0/include/node/node_buffer.h:28:40: note: candidate function not viable: requires 2
arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate, size_t length);
^
/Users/username/.node-gyp/5.1.0/include/node/node_buffer.h:36:40: note: candidate function not viable: requires 5
arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocalv8::Object New(v8::Isolate* isolate,
^
In file included from …/src/validation.cc:15:
…/node_modules/nan/nan.h:676:12: error: no viable conversion from ‘v8::MaybeLocalv8::Object’ to
‘v8::Localv8::Object
return node::Buffer::New(v8::Isolate::GetCurrent(), size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/username/.node-gyp/5.1.0/include/node/v8.h:210:7: note: candidate constructor (the implicit copy constructor)
not viable: no known conversion from ‘v8::MaybeLocalv8::Object’ to ‘const v8::Localv8::Object &’ for 1st
argument
class Local {
^
/Users/username/.node-gyp/5.1.0/include/node/v8.h:210:7: note: candidate constructor (the implicit move constructor)
not viable: no known conversion from ‘v8::MaybeLocalv8::Object’ to ‘v8::Localv8::Object &&’ for 1st
argument
class Local {
^
/Users/username/.node-gyp/5.1.0/include/node/v8.h:214:13: note: candidate template ignored: could not match ‘Local’
against ‘MaybeLocal’
V8_INLINE Local(Local that)
^
/Users/username/.node-gyp/5.1.0/include/node/v8.h:326:13: note: candidate template ignored: could not match 'S
against ‘v8::MaybeLocalv8::Object
V8_INLINE Local(S
that)
^
In file included from …/src/validation.cc:15:
…/node_modules/nan/nan.h:683:26: error: no member named ‘Use’ in namespace ‘node::Buffer’
return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
^
In file included from …/src/validation.cc:7:
/Users/username/.node-gyp/5.1.0/include/node/v8.h:221:5: error: assigning to ‘v8::Primitive *volatile’ from
incompatible type ‘v8::Value *’
TYPE_CHECK(T, S);
^
~
/Users/username/.node-gyp/5.1.0/include/node/v8.h:180:37: note: expanded from macro ‘TYPE_CHECK’
(static_cast<T volatile*>(0)) = static_cast<S*>(0);
^ ~~~~~~~~~~~~~~~~~~
…/node_modules/nan/nan.h:414:12: note: in instantiation of function template specialization
‘v8::Localv8::Primitive::Localv8::Value’ requested here
return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent())));
^
…/node_modules/nan/nan.h:398:30: note: expanded from macro ‘NanEscapeScope’

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                         ^

In file included from …/src/validation.cc:7:
/Users/username/.node-gyp/5.1.0/include/node/v8.h:221:5: error: assigning to 'v8::Boolean volatile’ from incompatible
type 'v8::Value
TYPE_CHECK(T, S);
^~~~~~~~~~~~~~~~
/Users/username/.node-gyp/5.1.0/include/node/v8.h:180:37: note: expanded from macro ‘TYPE_CHECK’
(static_cast<T volatile
>(0)) = static_cast<S
>(0);
^ ~~~~~~~~~~~~~~~~~~
…/node_modules/nan/nan.h:424:12: note: in instantiation of function template specialization
‘v8::Localv8::Boolean::Localv8::Value’ requested here
return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent())));
^
…/node_modules/nan/nan.h:398:30: note: expanded from macro ‘NanEscapeScope’

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                         ^

In file included from …/src/validation.cc:7:
/Users/username/.node-gyp/5.1.0/include/node/v8.h:221:5: error: assigning to 'v8::Function volatile’ from
incompatible type 'v8::Value
TYPE_CHECK(T, S);
^~~~~~~~~~~~~~~~
/Users/username/.node-gyp/5.1.0/include/node/v8.h:180:37: note: expanded from macro ‘TYPE_CHECK’
(static_cast<T volatile
>(0)) = static_cast<S
>(0);
^ ~~~~~~~~~~~~~~~~~~
…/node_modules/nan/nan.h:1514:12: note: in instantiation of function template specialization
‘v8::Localv8::Function::Localv8::Value’ requested here
return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex)
^
…/node_modules/nan/nan.h:398:30: note: expanded from macro ‘NanEscapeScope’

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                         ^

In file included from …/src/validation.cc:7:
/Users/username/.node-gyp/5.1.0/include/node/v8.h:221:5: error: assigning to 'v8::Object volatile’ from incompatible
type 'v8::Value
TYPE_CHECK(T, S);
^~~~~~~~~~~~~~~~
/Users/username/.node-gyp/5.1.0/include/node/v8.h:180:37: note: expanded from macro ‘TYPE_CHECK’
(static_cast<T volatile
>(0)) = static_cast<S
>(0);
^ ~~~~~~~~~~~~~~~~~~
…/node_modules/nan/nan.h:1632:12: note: in instantiation of function template specialization
‘v8::Localv8::Object::Localv8::Value’ requested here
return NanEscapeScope(handle->Get(NanNew(key)).Asv8::Object());
^
…/node_modules/nan/nan.h:398:30: note: expanded from macro ‘NanEscapeScope’

define NanEscapeScope(val) scope.Escape(_NanEnsureLocal(val))

                         ^

9 errors generated.
make: *** [Release/obj.target/validation/src/validation.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.0.0
gyp ERR! command “/usr/local/Cellar/node/5.1.0/bin/node” “/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /Users/username/node_modules/appium/node_modules/ws/node_modules/utf-8-validate
gyp ERR! node -v v5.1.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: node-gyp rebuild
npm WARN install:[email protected] Exit status 1

[email protected] install /Users/username/node_modules/appium/node_modules/appium-chromedriver
node install-npm.js

info Chromedriver Install Opening temp file to write chromedriver_mac32 to…
info Chromedriver Install Downloading http://chromedriver.storage.googleapis.com/2.18/chromedriver_mac32.zip
info Chromedriver Install Writing binary content to /var/folders/p7/_12xm90n76x4frwzzh452jvc0000gq/T/1151021-1546-140zwdr/chromedriver_mac32.zip…
info Chromedriver Install Extracting /var/folders/p7/_12xm90n76x4frwzzh452jvc0000gq/T/1151021-1546-140zwdr/chromedriver_mac32.zip to /var/folders/p7/_12xm90n76x4frwzzh452jvc0000gq/T/1151021-1546-140zwdr/chromedriver_mac32
info Chromedriver Install Creating /Users/username/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac…
info Chromedriver Install Copying unzipped binary, reading from /var/folders/p7/_12xm90n76x4frwzzh452jvc0000gq/T/1151021-1546-140zwdr/chromedriver_mac32/chromedriver…
info Chromedriver Install Writing to /Users/username/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver…
info Chromedriver Install /Users/username/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver successfully put in place

It seems like there’s problems with your version of node. You can try brew install node, then run appium’s reset.sh. I saw a similar error here. Good luck!

@shermaneric

Many thanks for the help.

Issue has been resolved by using an older version of node (4.0.0).

1 Like