npm install 的时候报错,如何解决?


20238 error code EPERM
20239 error syscall lstat
20240 error path D:\MyWorkAPP\IDEASPACE\ysdwzyjc\ruoyi-ui\node_modules\.staging\echarts-9cb80352\dist\echarts-en.simple.js
20241 error errno -4048
20242 error Error: EPERM: operation not permitted, lstat 'D:\MyWorkAPP\IDEASPACE\ysdwzyjc\ruoyi-ui\node_modules\.staging\echarts-9cb80352\dist\echarts-en.simple.js'
20242 error  [OperationalError: EPERM: operation not permitted, lstat 'D:\MyWorkAPP\IDEASPACE\ysdwzyjc\ruoyi-ui\node_modules\.staging\echarts-9cb80352\dist\echarts-en.simple.js'] {
20242 error   cause: [Error: EPERM: operation not permitted, lstat 'D:\MyWorkAPP\IDEASPACE\ysdwzyjc\ruoyi-ui\node_modules\.staging\echarts-9cb80352\dist\echarts-en.simple.js'] {
20242 error     errno: -4048,
20242 error     code: 'EPERM',
20242 error     syscall: 'lstat',
20242 error     path: 'D:\\MyWorkAPP\\IDEASPACE\\ysdwzyjc\\ruoyi-ui\\node_modules\\.staging\\echarts-9cb80352\\dist\\echarts-en.simple.js'
20242 error   },
20242 error   stack: "Error: EPERM: operation not permitted, lstat 'D:\\MyWorkAPP\\IDEASPACE\\ysdwzyjc\\ruoyi-ui\\node_modules\\.staging\\echarts-9cb80352\\dist\\echarts-en.simple.js'",
20242 error   errno: -4048,
20242 error   code: 'EPERM',
20242 error   syscall: 'lstat',
20242 error   path: 'D:\\MyWorkAPP\\IDEASPACE\\ysdwzyjc\\ruoyi-ui\\node_modules\\.staging\\echarts-9cb80352\\dist\\echarts-en.simple.js',
20242 error   parent: 'ruoyi-ui'
20242 error }
20243 error The operation was rejected by your operating system.
20243 error It's possible that the file was already in use (by a text editor or antivirus),
20243 error or that you lack permissions to access it.
20243 error
20243 error If you believe this might be a permissions issue, please double-check the
20243 error permissions of the file and its containing directories, or try running
20243 error the command again as root/Administrator.
20244 verbose exit [ -4048, true ]

权限问题使用 管理员身份运行 cmd窗口

看到错误里面说的是不允许操作,也有可能是没有权限:operation not permitted,error or that you lack permissions to access it;
排查两个问题:

  1. 你npm install 使用的 是不是ssh://@git 这种方式下载的 node_modules,这种方式很多时候要设置 SSH_KEY,请切换为 https://@git 这种方式;
  2. npm install 下载的 node_modules 的包是共有包还是私有包,私有的可以在项目里面 使用 .npmrc 配置文件修改下载路径;
    个人遇到类似问题的解决方案