1、问题描述?
C:\Users\Administrator>npm install -g appium@1.19.0
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Program Files\nodejs\node_cache\_cacache
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_cache\_cacache'
npm ERR! [Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_cache\_cacache'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'C:\\Program Files\\nodejs\\node_cache\\_cacache'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! Log files were not written due to an error writing to the directory: C:\Program Files\nodejs\node_cache\_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
翻译:没有权限操作指定的目录。
问题原因:在执行npm install命令的时候,系统不允许操作node_cache/_cacache目录。
2、解决办法?
知道原因后,解决办法是比较简单的,让系统给npm操作权限即可。
【右键"nodejs目录",选择属性】
【点击"安全"选项】
一般个人电脑登录的都是Administrators用户
【点击编辑】
【完全控制】
选择对应的用户,点击完全控制,然后点击应用。
如果你不知道你自己是那个用户登录的,你就把所有的用户都操作一下。
恭喜你搞定!