Appium server安装踩坑记

最近准备开展app自动化测试,逐步搭建appium自动花测试框架

安装准备

1.安装nodejs

安装完成后检查 :
 node -version  
 npm -version

2.安装JDK
3.安装Android SDK
准备环境完成:
1.暂缓cnpm

**  npm install -g cnpm --registry=**[**https://registry.npm.taobao.org**](https://registry.npm.taobao.org/)
检查是否成功:
cnpm -v

2.通过cnpm安装appium server

cnpm install -g appium --no-cache

3.安装完成后安装appium-doctor

cnpm install -g appium-doctor
注意添加-g参数,之后就可以在命令行运行appium-doctor查看appium运行环境是否配置正常

4.使用appium-doctor检查是否正常

实践过程中遇到报错

  at IncomingMessage.handleStreamEnd (C:\Users\user\AppData\Roaming\npm\node_modules\appium\node_modules\_axios@0.21.4@axios\lib\adapters\http.js:269:11)
    at IncomingMessage.emit (node:events:406:35)
    at endReadableNT (node:internal/streams/readable:1331:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
[08:54:38] Downloading Chromedriver can be skipped by using the '--chromedriver-skip-install' flag or setting the 'APPIUM_SKIP_CHROMEDRIVER_INSTALL' environment variable.
[npminstall:runscript:error] appium-android-driver@4.50.0 › appium-chromedriver@^4.13.0 scripts.postinstall run "node install-npm.js" error: Error [RunScriptError]: Run "C:\WINDOWS\system32\cmd.exe /d /s /c node install-npm.js" error, exit code 1
    at ChildProcess.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\cnpm\node_modules\runscript\index.js:96:21)
    at ChildProcess.emit (node:events:394:28)
    at maybeClose (node:internal/child_process:1067:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
  stdio: [Object],
  exitcode: 1
}
Install fail! RunScriptError: post install error, please remove node_modules before retry!
Run "C:\WINDOWS\system32\cmd.exe /d /s /c node install-npm.js" error, exit code 1
RunScriptError: Run "C:\WINDOWS\system32\cmd.exe /d /s /c node install-npm.js" error, exit code 1
    at ChildProcess.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\cnpm\node_modules\runscript\index.js:96:21)
    at ChildProcess.emit (node:events:394:28)
    at maybeClose (node:internal/child_process:1067:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npminstall version: 5.1.1
npminstall args: D:\software\nodej\node.exe C:\Users\user\AppData\Roaming\npm\node_modules\cnpm\node_modules\npminstall\bin\install.js --fix-bug-versions --china --userconfig=C:\Users\user\.cnpmrc --disturl=https://npmmirror.com/mirrors/node --registry=https://registry.npmmirror.com -g appium --no-cache

解决方案

使用命令sudo npm install -g npm
重新安装npm
启动appium 成功