无法安装任何NPM软件包,错误4058 [英] Can't install any NPM package, error 4058

查看:1373
本文介绍了无法安装任何NPM软件包,错误4058的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在项目中安装Grunt.它曾经可以正常运行,但是现在由于某种原因,它没有运行.每次我尝试安装Grunt时,都会出现此错误:

I'm trying to install Grunt on my project. It used to work perfectly, but now for some reason, it does not. Every time i try to install Grunt, I got this error:

npm ERR! path C:\irrelevent\path\project\node_modules\ansi-styles
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\irrelevent\path\project\node_modules\ansi-styles' -> 'C:\irrelevent\path\project\.ansi-styles.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Me\AppData\Roaming\npm-cache\_logs\2018-04-03T00_52_10_105Z-debug.log

奇怪的是丢失的包每次都会更改.
我尝试验证缓存,删除node_modules文件夹,然后使用--force清理缓存.卸载NPM和NodeJS,重新启动计算机.没有机会.
出于安全原因,我不得不格式化计算机,我使用了项目文件夹,但没有使用Roaming文件夹,我不知道这是否有影响,但是自从重新安装NPM后就不会了.

The weird thing is that the missing package change every time.
I try verifying the cache, removing the node_modules folder, cleaning the cache using --force. Uninstall NPM and NodeJS, restart my computer. No chances.
I had to format my computer for security reason, I took the project folder but not the Roaming folder, I don't know if this had an impact, but it shouldn't since I reinstalled NPM.

我不确定这是否有帮助,但这是我的package.json

I'm not sure if this will help but here is my package.json

{
 "name": "project",
 "version": "2.1.0",
 "repository": "project-2.0",
 "devDependencies": {
   "grunt": "^1.0.2",
   "grunt-cli": "^1.2.0",
   "grunt-contrib-concat": "~1.0.1",
   "grunt-contrib-copy": "^1.0.0",
   "grunt-contrib-cssmin": "~2.0.0",
   "grunt-contrib-jshint": "~1.1.0",
   "grunt-contrib-uglify": "~2.2.0",
   "grunt-contrib-watch": "~1.0.0",
   "grunt-html-build": "^0.7.1",
   "grunt-real-favicon": "^0.2.2"
 },
 "dependencies": {
   "angular-bootstrap-colorpicker": "^3.0.31",
   "angularjs-geolocation": "^0.1.3",
   "sprintf-js": "^1.1.1"
 }
}

推荐答案

尝试以下步骤:

  • 删除package-lock.json并再次运行NPM.
  • 确保没有其他的node.js进程正在运行(检查任务管理器)
  • 如果您使用的是Visual Studio代码,请关闭它并尝试再次运行npm install.
  • 如果其他所有方法均失败,请重新启动计算机.
  • Delete package-lock.json and run NPM again.
  • Ensure no other processes of node.js are running (check task manager)
  • If you are using visual studio code, close it and try running npm install again.
  • If all else fails, restart your computer.

在此处查看主题: https://github.com/npm/npm/issues/17444

这篇关于无法安装任何NPM软件包,错误4058的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆