本人小白,在VScode终端中进行npm install,报错,如下
PS E:\SVN\学生管理系统\代码\crqms\crqms-web> npm install
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path D:\Program Files (x86)\nodejs\node_cache\_locks
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'D:\Program Files (x86)\nodejs\node_cache\_locks'
npm ERR! [Error: EPERM: operation not permitted, mkdir 'D:\Program Files (x86)\nodejs\node_cache\_locks'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
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.
找了好多办法,依然解决不了我的问题,根据上面的提示,我没有获得管理员权限,
于是,打开VScode用管理员身份打开,可是这样每次都这样,好麻烦。放弃这种方法
废话不说了,我的解决办法如下:
- 找到本机的node安装目录,我的目录是:D:\Program Files (x86)\nodejs
- 随意右击nodejs中的一个文件,观察它的删除和重命名,发现前面有个盾牌,如下所示
- 这个盾牌意思是需要管理员权限的,普通用户是没有它的所有权限,所以我们需要给普通用户添加管理员一样的权限
- 右击nodejs文件夹,点击属性
- 点击安全
- 点击编辑
将这些权限都勾选上,点击“应用”,出现如下:
点击“确定”后,在打开原来的nodejs文件夹,右键查看,发现已经没有盾牌了
再到VScode中进行npm install
成功解决了