Ошибка 4058 npm

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:irreleventpathprojectnode_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:irreleventpathprojectnode_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:UsersMeAppDataRoamingnpm-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"
 }
}

when I try to install dependencies for my package i receive the folowing error

npm WARN package@1.0.0 No description
npm WARN package@1.0.0 No repository field.

npm ERR! path C:Usersuser_nameDesktoptypeScript_react_webpack_app_templatenode_modulestypescript
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:Usersuser_nameDesktoptypeScript_react_webpack_app_templatenode_modulestypescript' -> 'C:Usersuser_nameDesktoptypeScript_react_webpack_app_templatenode_modules.typescript.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:Usersuser_nameAppDataRoamingnpm-cache_logs2017-07-07T08_55_48_803Z-debug.log

my package.json

{
  "name": "package",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.25.0",
    "babel-loader": "^7.1.1",
    "babel-preset-es2017": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "ts-loader": "^2.2.2",
    "typescript": "^2.4.1",
    "webpack": "^3.0.0"
  },
  "dependencies": {
    "react": "^15.6.1",
    "react-dom": "^15.6.1"
  }
}

if I install package as npm install typescript all works fine.
What can be solution for this problem?

The «Error 4058» is a common issue encountered by users when trying to install an NPM package in Javascript. The error message often states that the package installation has failed due to a permission error or network connectivity issue. In this scenario, it is important to address the root cause of the error to ensure that packages can be installed correctly and your project runs smoothly.

Method 1: Clear NPM Cache

To clear the NPM cache, you can use the following command:

This will clear the entire NPM cache. If you want to clear the cache for a specific package, you can use:

npm cache clean <package-name>

For example:

You can also clear the cache programmatically using the npm-cache package:

const npmCache = require('npm-cache');

npmCache.clear((err, result) => {
  if (err) {
    console.error(err);
  } else {
    console.log(result);
  }
});

This will clear the entire NPM cache programmatically.

In addition to clearing the cache, you can also try updating NPM to the latest version:

npm install -g npm@latest

This will update NPM to the latest version.

If you’re still having issues, you can try deleting the node_modules folder and running npm install again:

rm -rf node_modules
npm install

This will delete the node_modules folder and reinstall all dependencies.

Finally, you can try running npm install with the --verbose flag to get more information about the installation process:

This will output more detailed information about the installation process, which can help you diagnose any issues.

Method 2: Reinstall NPM with Administrative Privileges

If you are encountering the error 4058 while trying to install any NPM package, you may need to reinstall NPM with administrative privileges. Here are the steps to do so:

  1. Open your command prompt or terminal with administrative privileges.

  2. Uninstall NPM by running the following command:

  1. Remove any remaining NPM files by running the following command:
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
  1. Reinstall NPM with administrative privileges by running the following command:
  1. Check if NPM is installed correctly by running the following command:

This should output the version of NPM installed on your machine.

  1. Finally, try installing the package you were trying to install before the error 4058 occurred. You should now be able to install it without any issues.
npm install <package-name>

That’s it! By following these steps, you should be able to fix the error 4058 and install any NPM package with ease.

Method 3: Disable Firewall or Proxy Settings

If you are facing an issue while installing NPM packages and getting the error message «Can’t Install Any NPM Package, Error 4058», then it might be due to the firewall or proxy settings. In this case, you can try disabling the firewall or proxy settings to fix the issue. Here are the steps to do it:

Step 1: Disable Firewall

You can disable the firewall temporarily to check if it is causing the issue. Here is how you can do it:

Windows

netsh advfirewall set allprofiles state off

macOS

Step 2: Disable Proxy Settings

You can also disable the proxy settings to fix the issue. Here is how you can do it:

Windows

set HTTP_PROXY=
set HTTPS_PROXY=
set NO_PROXY=

macOS

unset HTTP_PROXY
unset HTTPS_PROXY
unset NO_PROXY

Step 3: Install NPM Package

Once you have disabled the firewall or proxy settings, you can try installing the NPM package again. Here is an example:

npm install <package-name>

This should fix the issue and you should be able to install NPM packages without any errors.

Note: It is not recommended to disable the firewall or proxy settings permanently as it can cause security issues. You should enable them again once you have installed the required NPM packages.

Method 4: Manually Download Package and Install

If you are facing the error Can't install any NPM package, error 4058 while installing an NPM package, you can try manually downloading the package and installing it. Here are the steps to do it:

  1. Go to the NPM package’s page on the NPM registry website.
  2. Click on the «Download» button to download the package as a .tgz file.
  3. Move the downloaded .tgz file to your project directory.
  4. Open a terminal window and navigate to your project directory.
  5. Run the following command to install the package using the downloaded .tgz file:
npm install ./<package-name>-<version>.tgz

Replace <package-name> and <version> with the actual name and version of the package.

Here is an example command to install the lodash package version 4.17.21 using the downloaded .tgz file:

npm install ./lodash-4.17.21.tgz

That’s it! You have manually downloaded and installed the NPM package.

Method 5: Check Network Connectivity and Update Proxy Settings

If you are facing an error 4058 while trying to install any NPM package, it could be due to network connectivity or proxy settings. Here’s how you can fix it:

Step 1: Check Network Connectivity

To check if your network is working fine, you can use the ping command in your terminal. For example:

This should return a response from the server. If it doesn’t, then there might be an issue with your network connectivity.

Step 2: Update Proxy Settings

If you are behind a proxy, you might need to update your proxy settings. You can do this by running the following command in your terminal:

npm config set proxy http://yourproxyurl.com:8080

Replace yourproxyurl.com and 8080 with your proxy URL and port number respectively.

You might also need to update the https-proxy setting:

npm config set https-proxy http://yourproxyurl.com:8080

Step 3: Clear NPM Cache

Sometimes, clearing the NPM cache can also help in resolving installation issues. You can do this by running the following command:

Step 4: Install the Package

Now that you have updated your proxy settings and cleared the NPM cache, you can try installing the package again:

This should install the package without any issues.

Introduction

Recently, I’ve faced different issues when tryng npm install in some of the project I’ve been working with.

Environment

  • Windows 10 (OS Build 15063.413)
  • Node version: 8.1.2
  • NPM version: 5.0.3

Every time I tried npm install or install a isolated package I got errors like this one:
ENOENT 4058

Problem

1
2
3
4
5
6
7
_npm ERR! path GitHubreact-typescript-webpack2-cssModules-postCSSnode_modulests-loader
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'D:GitHubreact-typescript-webpack2-cssModules-postCSSnode_m
odulests-loader' -> 'GitHubreact-typescript-webpack2-cssModules-postCSSnode_modules.ts-loader.DELETE'
npm ERR! enoent This is related to npm not being able to find a file._

Solution

The solution for my specific scenario was:

1. Close VS Code
2. Remove package-lock.json, node_modules and npm cache

1
2
3
4

del package-lock.json
rd /s /q node_modules
npm cache clear --force
1
2
3
4

rm package-lock.json
rm -rf node_modules/
npm cache clear --force

3. Retry npm i

Read more…

If you still have this problem, read this: https://github.com/npm/npm/issues/10826

Copyright Notice: All articles in this blog are licensed under CC BY-SA 4.0 unless stating additionally.

Description:
npm install has been complaining about lots of vulnerabilities in my package.json
I recently upgraded to node.js 18.x for some REST api experimentation against mongodb (just a TS project)
I guess that broken my ionic3.x app projects which now won’t build.
I reverted to node.js v14.15.5 according to an SO post.
But my ionic serve is still broken
I tried deleting node_modules folder and recreate it either of the following fail

npm i --legacy-deps  
npm i --force 

The error initially complained about this location

npm ERR! enoent ENOENT: no such file or directory, open 'C:UsersAXMAppDataLocalnpm-cache_cacachetmpgit-cloneiEYZWfpackage.json'

so I did the following according to another post

md C:npm-cache
npm config set cache C:npm-cache

Still the same error and no node_modules created.

$ npm i --legacy-peer-deps
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:npm-cache_cacachetmpgit-cloneJh1opn/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:npm-cache_cacachetmpgit-cloneJh1opnpackage.json'
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:npm-cache_logs2022-05-13T06_03_59_853Z-debug-0.log

Here is my packages.json

{
    "name": "mumti",
    "version": "0.0.1",
    "author": "MUMTI Labs",
    "homepage": "https://mumti.org/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve",
        "watch": "ionic-app-scripts watch && beep ",
        "serve:before": "watch",
        "emulate:before": "build",
        "deploy:before": "build",
        "build:before": "build",
        "run:before": "build",
        "run:after": "beep",
        "serve:after": "beep",
        "beep": "bash.exe beep.sh",
        "beep0": "bash.exe -c "echo -en '\a' " ",
        "releasePWA": "ionic cordova build browser --prod --release"
    },
    "dependencies": {
        "@angular/common": "5.0.3",
        "@angular/compiler": "5.0.3",
        "@angular/compiler-cli": "5.0.3",
        "@angular/core": "5.0.3",
        "@angular/forms": "5.0.3",
        "@angular/platform-browser": "^5.0.3",
        "@angular/platform-browser-dynamic": "5.0.3",
        "@ionic-native/android-full-screen": "^4.20.0",
        "@ionic-native/app-version": "^4.20.0",
        "@ionic-native/clipboard": "4.5.2",
        "@ionic-native/core": "4.5.2",
        "@ionic-native/document-viewer": "^4.7.0",
        "@ionic-native/file": "^4.7.0",
        "@ionic-native/file-transfer": "^4.7.0",
        "@ionic-native/in-app-browser": "4.5.2",
        "@ionic-native/social-sharing": "4.5.2",
        "@ionic-native/splash-screen": "^4.7.0",
        "@ionic-native/status-bar": "4.5.2",
        "@ionic-native/toast": "4.6.0",
        "@ionic/pro": "1.0.16",
        "@ionic/storage": "2.1.3",
        "@types/youtube": "0.0.46",
        "archiver": "^5.3.1",
        "child_process": "^1.0.2",
        "clipboard-js": "0.3.3",
        "com.verso.cordova.clipboard": "https://github.com/VersoSolutions/CordovaClipboard.git",
        "cordova-browser": "5.0.3",
        "cordova-clipboard": "~1.0.0",
        "cordova-plugin-device": "1.1.4",
        "cordova-plugin-file": "^6.0.1",
        "cordova-plugin-file-transfer": "^1.7.1",
        "cordova-plugin-fullscreen": "^1.2.0",
        "cordova-plugin-inappbrowser": "~1.7.1-dev",
        "cordova-plugin-ionic-webview": "^1.1.11",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-whitelist": "^1.3.3",
        "cordova-plugin-x-socialsharing": "~5.1.6",
        "cordova-plugin-x-toast": "~2.6.0",
        "cordova-sqlite-storage": "~2.0.3",
        "danielsogl-cordova-plugin-clipboard": "1.0.2",
        "ionic-angular": "3.9.2",
        "ionic-plugin-keyboard": "~2.2.1",
        "ionicons": "3.0.0",
        "node-apk": "^1.1.1",
        "rxjs": "5.5.2",
        "sw-toolbox": "3.6.0",
        "url-exist": "^3.0.0",
        "zone.js": "0.8.18"
    },
    "devDependencies": {
        "@ionic/app-scripts": "^3.2.4",
        "@types/node": "^9.4.7",
        "cordova-android": "^10.1.2",
        "cordova-plugin-apkupdater": "^4.0.0",
        "cordova-plugin-app-version": "^0.1.14",
        "tslint": "^5.10.0",
        "tslint-ionic-rules": "0.0.16",
        "typescript": "^2.8.3",
        "viewport-units-buggyfill": "0.6.2"
    },
    "cordovaPlugins": [
        "cordova-plugin-whitelist",
        "cordova-plugin-console",
        "cordova-plugin-statusbar",
        "cordova-plugin-device",
        "cordova-plugin-splashscreen",
        "ionic-plugin-keyboard",
        "cordova-plugin-x-socialsharing"
    ],
    "cordovaPlatforms": [
        {
            "platform": "android",
            "version": "",
            "locator": "android"
        },
        {
            "platform": "browser",
            "version": "",
            "locator": "browser"
        }
    ],
    "description": "UPS.ion: project",
    "config": {
        "ionic_source_map": "source-map",
        "ionic_copy": "./copy.config.js"
    },
    "cordova": {
        "plugins": {
            "cordova-sqlite-storage": {},
            "cordova-plugin-x-toast": {},
            "cordova-clipboard": {},
            "cordova-plugin-file-transfer": {},
            "cordova-plugin-file": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "cordova-plugin-device": {},
            "cordova-plugin-ionic-webview": {},
            "com.verso.cordova.clipboard": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-inappbrowser": {},
            "cordova-plugin-x-socialsharing": {},
            "cordova-plugin-fullscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-apkupdater": {},
            "cordova-plugin-app-version": {}
        },
        "platforms": [
            "browser"
        ]
    }
}

Here is ionic info
`
image

Just 4 days ago I was able to build both an APK and build for the browser, now everything is broken. 🙏

Понравилась статья? Поделить с друзьями:
  • Ошибка 405 метод запроса не разрешен
  • Ошибка 407 билайн тв что означает
  • Ошибка 4058 flashtool как исправить
  • Ошибка 405 киви кошелек
  • Ошибка 407 squid