Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
861 views
in Technique[技术] by (71.8m points)

javascript - Can't install any NPM package, error 4058

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:irreleventpathproject
ode_modulesansi-styles
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:irreleventpathproject
ode_modulesansi-styles' -> 'C:irreleventpathproject.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:UsersMeAppDataRoaming
pm-cache\_logs2018-04-03T00_52_10_105Z-debug.log

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.

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"
 }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try these steps:

  • 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.

See thread here: https://github.com/npm/npm/issues/17444


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...