无法安装appium@next:os.tmpDir报错及修改无效求助
Appium@Next安装报错:
os.tmpDir is not a function 解决方案求助 环境与操作步骤
- 系统:Windows 10 64位
- 执行命令:
npm i -g appium@next npm audit fix --force
核心错误信息
npm ERR! path C:\Users\shelly\node_modules\appium\node_modules\appium-chromedriver npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install-npm.js npm ERR! info Chromedriver Install Opening temp file to write chromedriver_win32 to... npm ERR! TypeError: os.tmpDir is not a function npm ERR! at tempDir (C:\Users\shelly\node_modules\appium-support\lib\tempdir.js:14:31)
尝试过的无效方法
手动修改C:\Users\shelly\node_modules\appium-support\lib\tempdir.js文件,将os.tmpDir改为os.tmpdir,但错误依然存在。
完整错误日志
npm WARN deprecated appium-atoms@0.0.5: Package moved into appium-remote-debugger npm WARN deprecated appium-uiauto@1.10.10: Use appium-ios-driver npm WARN deprecated lodash-node@2.4.1: This package is discontinued. Use lodash@^4.0.0. npm WARN deprecated appium-instruments@2.0.6: Use appium-ios-driver npm WARN deprecated core-js@0.9.18: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js. npm WARN deprecated core-js@1.2.7: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js. npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js. npm WARN cleanup Failed to remove some directories [ npm WARN cleanup [ npm WARN cleanup 'C:\\Users\\shelly\\node_modules\\bufferutil', npm WARN cleanup [Error: EBUSY: resource busy or locked, rmdir 'C:\Users\shelly\node_modules\bufferutil'] { npm WARN cleanup errno: -4082, npm WARN cleanup code: 'EBUSY', npm WARN cleanup syscall: 'rmdir', npm WARN cleanup path: 'C:\\Users\\shelly\\node_modules\\bufferutil' npm WARN cleanup } npm WARN cleanup ], npm WARN cleanup [ npm WARN cleanup 'C:\\Users\\shelly\\node_modules\\utf-8-validate', npm WARN cleanup [Error: EBUSY: resource busy or locked, rmdir 'C:\Users\shelly\node_modules\utf-8-validate'] { npm WARN cleanup errno: -4082, npm WARN cleanup code: 'EBUSY', npm WARN cleanup syscall: 'rmdir', npm WARN cleanup path: 'C:\\Users\\shelly\\node_modules\\utf-8-validate' npm WARN cleanup } npm WARN cleanup ] npm WARN cleanup ] npm ERR! code 1 npm ERR! path C:\Users\shelly\node_modules\appium\node_modules\appium-chromedriver npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install-npm.js npm ERR! info Chromedriver Install Opening temp file to write chromedriver_win32 to... npm ERR! TypeError: os.tmpDir is not a function npm ERR! at tempDir (C:\Users\shelly\node_modules\appium-support\lib\tempdir.js:14:31) npm ERR! at generateName (C:\Users\shelly\node_modules\appium-support\lib\tempdir.js:29:20) npm ERR! at Object.open (C:\Users\shelly\node_modules\appium-support\lib\tempdir.js:34:18) npm ERR! at Object.tryCatcher (C:\Users\shelly\node_modules\appium-support\node_modules\bluebird\js\main\util.js:26:23) npm ERR! at Object.ret [as open] (eval at makeNodePromisifiedEval (C:\Users\shelly\node_modules\appium-support\node_modules\bluebird\js\main\promisify.js:163:12), <anonymous>:13:39) npm ERR! at installForPlatform$ (C:\Users\shelly\node_modules\appium\node_modules\appium-chromedriver\build\lib\lib\install.js:80:32) npm ERR! at tryCatch (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:67:40) npm ERR! at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:294:22) npm ERR! at GeneratorFunctionPrototype.prototype.<computed> [as next] (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:100:21) npm ERR! at invoke (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:136:37) npm ERR! at enqueueResult (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:167:17) npm ERR! at new Promise (<anonymous>) npm ERR! at new exp (C:\Users\shelly\node_modules\core-js\library\modules\$.def.js:38:36) npm ERR! at AsyncIterator.enqueue (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:166:12) npm ERR! at AsyncIterator.prototype.<computed> [as next] (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:100:21) npm ERR! at Object.runtime.async (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:192:12) npm ERR! at installForPlatform (C:\Users\shelly\node_modules\appium\node_modules\appium-chromedriver\build\lib\install.js:151:30) npm ERR! at install$ (C:\Users\shelly\node_modules\appium\node_modules\appium-chromedriver\build\lib\lib\install.js:122:9) npm ERR! at tryCatch (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:67:40) npm ERR! at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:294:22) npm ERR! at GeneratorFunctionPrototype.prototype.<computed> [as next] (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:100:21) npm ERR! at GeneratorFunctionPrototype.invoke (C:\Users\shelly\node_modules\babel-runtime\regenerator\runtime.js:136:37) npm ERR! at processTicksAndRejections (node:internal/process/task_queues:96:5) npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\shelly\AppData\Local\npm-cache\_logs\2023-05-12T05_38_22_721Z-debug-0.log
可行解决方案建议
1. 适配Node.js版本
os.tmpDir()是Node.js旧版API,已被废弃并替换为小写的os.tmpdir()。Appium@next的依赖可能未适配高版本Node.js,建议降级到Node.js 16.x LTS版本,再重新安装。
2. 清理残留后重新安装
- 卸载全局Appium:
npm uninstall -g appium - 强制清理npm缓存:
npm cache clean --force - 手动删除残留目录:
C:\Users\shelly\node_modules\appium及相关子文件夹 - 安装稳定版Appium(若无需尝鲜next版):
npm i -g appium
3. 全局修复API引用
若坚持使用Appium@next,需找到所有依赖中引用os.tmpDir()的文件(不止appium-support,appium-chromedriver的源码也可能有相关调用),全部替换为os.tmpdir()后,重新执行安装命令。
内容的提问来源于stack exchange,提问作者Shelly Gupta
相关产品推荐
相关产品推荐

