尝试在Ubuntu上使用Appium,但获取node.js:134错误

我已经安装了节点

sudo apt-get install -y nodejs 

和appium一起

 sudo npm install -g appium 

在这两种情况下,我都被迫在Ubuntu上使用sudo 。 https://github.com/appium/appium/blob/master/README.md上的appium页面说不要使用sudo但是我相信在Ubuntu上,可以(并且必须)按照节点页面的指示使用sudo在https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

当我尝试用appium &或甚至只是开始appium

 appium 

我明白了

 $ appium node.js:134 throw e; // process.nextTick error, or 'error' event on first tick ^ TypeError: Object prototype may only be an Object or null at Function.create (native) at Object.inherits (util.js:425:27) at Object.<anonymous> (/usr/lib/node_modules/appium/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_readable.js:63:6) at Module._compile (module.js:402:26) at Object..js (module.js:408:10) at Module.load (module.js:334:31) at Function._load (module.js:293:12) at require (module.js:346:19) at Object.<anonymous> (/usr/lib/node_modules/appium/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/readable.js:1:90) at Module._compile (module.js:402:26) 

我升级了节点,但似乎没有帮助:

 $ node -v v0.12.2 15:04:28 durrantm Castle2012 /home/durrantm/Dropbox/_/appium_mobile_testing/appium master $ appium error: Appium will not work if used or installed with sudo. Please rerun/install as a non-root user. If you had to install Appium using `sudo npm install -g appium`, the solution is to reinstall Node using a method (Homebrew, for example) that doesn't require sudo to install global npm packages. 

但是,当我卸载节点,然后尝试重新安装它没有sudo,如上所示,我得到:

 $ apt-get install nodejs E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? 

我尝试从本地build立源节点

 $ mkdir ~/local $ ./configure --prefix=~/local creating ./icu_config.gypi { 'target_defaults': { 'cflags': [], 'default_configuration': 'Release', 'defines': [], 'include_dirs': [], 'libraries': []}, 'variables': { 'clang': 0, 'gcc_version': 48, 'host_arch': 'x64', 'icu_small': 'false', 'node_install_npm': 'true', 'node_prefix': '/home/durrantm/local', 'node_shared_cares': 'false', 'node_shared_http_parser': 'false', 'node_shared_libuv': 'false', 'node_shared_openssl': 'false', 'node_shared_v8': 'false', 'node_shared_zlib': 'false', 'node_tag': '', 'node_use_dtrace': 'false', 'node_use_etw': 'false', 'node_use_mdb': 'false', 'node_use_openssl': 'true', 'node_use_perfctr': 'false', 'openssl_no_asm': 0, 'python': '/usr/bin/python', 'target_arch': 'x64', 'uv_library': 'static_library', 'uv_parent_path': '/deps/uv/', 'uv_use_dtrace': 'false', 'v8_enable_gdbjit': 0, 'v8_enable_i18n_support': 0, 'v8_no_strict_aliasing': 1, 'v8_optimized_debug': 0, 'v8_random_seed': 0, 'v8_use_snapshot': 'true', 'want_separate_host_toolset': 0}} creating ./config.gypi creating ./config.mk $ make ... $ make install ... 

但似乎没有帮助:

 $ npm install -g appium npm ERR! tar.unpack untar error /home/durrantm/.npm/appium/1.3.7/package.tgz npm ERR! Linux 3.13.0-49-generic npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "appium" npm ERR! node v0.12.2 npm ERR! npm v2.7.4 npm ERR! path /usr/local/lib/node_modules/appium npm ERR! code EACCES npm ERR! errno -13 npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/appium' npm ERR! at Error (native) npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/appium'] npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! path: '/usr/local/lib/node_modules/appium', npm ERR! fstream_type: 'Directory', npm ERR! fstream_path: '/usr/local/lib/node_modules/appium', npm ERR! fstream_class: 'DirWriter', npm ERR! fstream_stack: npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23', npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53', npm ERR! 'FSReqWrap.oncomplete (fs.js:95:15)' ] } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! Please include the following file with any support request: npm ERR! /home/durrantm/Downloads/node/npm-debug.log 15:47:13 durrantm Castle2012 /home/durrantm/Downloads/node master $ appium error: Appium will not work if used or installed with sudo. Please rerun/install as a non-root user. If you had to install Appium using `sudo npm install -g appium`, the solution is to reinstall Node using a method (Homebrew, for example) that doesn't require sudo to install global npm packages. 

我也做了

 sudo chown -R $(whoami) ~/.npm 

 sudo npm install -g appium ... lots of compile outpout, not errors, seems ok ... 

但我仍然得到

 $ appium error: Appium will not work if used or installed with sudo. Please rerun/install as a non-root user. If you had to install Appium using `sudo npm install -g appium`, the solution is to reinstall Node using a method (Homebrew, for example) that doesn't require sudo to install global npm packages. 

正如你已经提到的, Appium不应该与sudo一起安装。 而且我不会推荐你通过apt来安装节点 ,并不适合我。

更好地使用自制软件 – 这将允许您将Appium安装到没有sudo的主目录。 尝试以下方法

  1. 卸载先前使用apt安装的节点sudo apt-get remove node

  2. 按照说明安装自制软件 。 之后安装节点brew install node

  3. 现在尝试: npm install -g appium

如果你在homepath中遇到.npm文件夹的权限问题,比使用你提到的sudo chown -R $(whoami) ~/.npm