npm 版本升级或降级报错?

来源:2-1 webpack 究竟是什么?

会飞的铁蛋

2019-05-22

延续 https://coding.imooc.com/learn/questiondetail/121612.html 提到的问题自行百度搜索说是 npm 版本问题
但尝试升级或降级 npm 版本又提示错误信息:
升级:
$ npm install -g npm
npm WARN tarball tarball data for https://registry.npmjs.org/npm/-/npm-6.9.0.tgz (sha512-91V+zB5hDxO+Jyp2sUKS7juHlIM95dGQxTeQtmZI1nAI/7kjWXFipPrtwwKjhyKmV4GsS2LzJhrxRjGWsU9z/w==) seems to be corrupted. Trying one more time.
npm ERR! path C:\Users\Chiu\AppData\Local\Temp\npm-18544-0e318d54\unpack-b2e97d99\node_modules\aws-sign2\index.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\Chiu\AppData\Local\Temp\npm-18544-0e318d54\unpack-b2e97d99\node_modules\aws-sign2\index.js’
npm ERR! { [Error: EPERM: operation not permitted, unlink ‘C:\Users\Chiu\AppData\Local\Temp\npm-18544-0e318d54\unpack-b2e97d99\node_modules\aws-sign2\index.js’]
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink 'C:\Users\Chiu\AppData\Local\Temp\npm-18544-0e318d54\unpack-b2e97d99\node_modules\aws-sign2\index.js’
npm ERR! errno: -4048,
npm ERR! code: ‘EPERM’,
npm ERR! syscall: ‘unlink’,
npm ERR! path:
npm ERR! ‘C:\Users\Chiu\AppData\Local\Temp\npm-18544-0e318d54\unpack-b2e97d99\node_modules\aws-sign2\index.js’ },
npm ERR! isOperational: true,
npm ERR! stack:
npm ERR! ‘Error: EPERM: operation not permitted, unlink ‘C:\Users\Chiu\AppData\Local\Temp\npm-18544-0e318d54\unpack-b2e97d99\node_modules\aws-sign2\index.js’’,
npm ERR! errno: -4048,
npm ERR! code: ‘EPERM’,
npm ERR! syscall: ‘unlink’,
npm ERR! path:
npm ERR! ‘C:\Users\Chiu\AppData\Local\Temp\npm-18544-0e318d54\unpack-b2e97d99\node_modules\aws-sign2\index.js’ }
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 (though this is not recommended).

降级:
$ npm install -g npm@5.4.0
npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! zlib: unexpected end of file

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Chiu\AppData\Roaming\npm-cache_logs\2019-05-21T17_12_16_026Z-debug.log

啥原因咯,真的伤心了,需重新把 node 卸载再重新操作下吗?

写回答

2回答

Dell

2019-05-23

哈哈,官网还有这样的建议呢

0
1
会飞的铁蛋
是咯,简单而粗爆。npm中文网上的故障排除:有一项说道如果是 Windows 系统并且以前安装的 npm 损坏了,最简单的方法是从官方下载 node 安装包并重新安装。
2019-05-23
共1条回复

会飞的铁蛋

提问者

2019-05-22

可以了,参考官网建议:重装...

0
0

从基础到实战 手把手带你掌握新版Webpack4.0

知识点+项目实例+原理讲解 全方位解析Webpack4新版本

3627 学习 · 1291 问题

查看课程