NPM填坑之npm install 报错220425

252 阅读2分钟

一、npm install 报错

相信你一定会有这样的尴尬时候,明明哪儿都是对的,却得不到对的结果.这是为啥?自信研究了一下,可能是我们没有仔细研究.O(∩_∩)O哈哈哈~开个玩笑,来看看有没有这样的情景.

1.1这种情况是什么原因?

image.png

1.2原因很简单:没有这个版本,安装的时候找不到这个版本.请看提示:

image.png

好,换一个版本,或者直接只要大版本号,这下不会错了吧?

image.png

看到下面的报错,兼职想哭,别哭,复制粘贴总会吧?去找解决方案呗.

npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Program Files\nodejs\node_modules\.staging
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'
npm ERR!  [OperationalError: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'mkdir',
npm ERR!     path: 'C:\\Program Files\\nodejs\\node_modules\\.staging'
npm ERR!   },
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'C:\\Program Files\\nodejs\\node_modules\\.staging',
npm ERR!   parent: '@types/jscodeshift'
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! A complete log of this run can be found in:
npm ERR!     C:\Users\DESKTOP-220413\AppData\Roaming\npm-cache\_logs\2022-04-25T08_08_35_877Z-debug.log

高高兴兴去搜索,结果还以为真的找到答案,真的找到了,1.7W的浏览量,不错的.

image.png

点进去一看究竟.

image.png

推荐两个方案,其中一个删文件,另外一个是清缓存啥的 试了一下,并没有结果.仔细一想,并不对呀,刚才的报错没看完,从头看看到底啥,逮住两句看了一下,大概意思是没有权限,所以拒绝了.

image.png

突然间想到刚才没有用管理员身份运行命令行,会不会是这个问题.

image.png

果然并不是管理员什么.好的换管理员身份试试呗.

image.png

不得不说,问题确实是这个.哎,这就是所谓的填坑吗?

二、总结

其实,我们有时候都在想不要浪费时间,直接找结果,但是有些结果人家是参考答案,并非标准答案,我们每一个人遇到的问题应该都不一样,多花点时间看看具体问题,可能就是少花时间.您说呢?