Npm Please try using this command again as root/administrator

后端 未结 30 723
旧巷少年郎
旧巷少年郎 2020-12-02 06:38

I\'ve been desperately trying to install modules using node.js but it always fails getting packages with npm.

I logged in as Administrator and used powershell/cmd wi

相关标签:
30条回答
  • 2020-12-02 06:52

    WHAT WORKED FOR ME

    I ran Command Prompt as Administrator. This helped partially - as I no longer got the error, "Please try using this command again as root/administrator". I was trying to install Cordova. To do it successfully, I also had to do the following:

    (1) "npm update node", plus...

    (2) I also added the " -g " in the >>npm install cordova<<. In other words, type this: >>npm install -g cordova<<

    ~~~ FOR WINDOWS 8.1 ~~~

    "RUN AS ADMINISTRATOR" COMMAND PROMPT

    For windows 8.1, I don't have an ACCESSORIES group when I click START > ALL PROGRAMS. But I do have that older -- but trusty and reliable -- START BUTTON and START MENU - thanks to the free Classic Start Menu app. So, with that installed....

    ALTERNATIVE #1:

    1. Type "cmd" in the SEARCH BOX at the bottom of the START menu.  
    2. When cmd.exe shows up in the top of the search results, right click it and select RUN AS ADMINISTRATOR.
    

    ALTERNATIVE #2 If you already have a Command Prompt window open and running - and you want to open another one to Run As Administrator:

    1. Locate the Command Prompt app icon in the Taskbar (usually along the bottom of you screen unless you have moved it a different dock/location).
    2. Right click the app icon.
    3. Now, right click "COMMAND PROMPT" and select RUN AS ADMINISTRATOR. 
    

    Hope this helps someone.

    0 讨论(0)
  • 2020-12-02 06:54

    A solution that worked, is to close all PowerShell and cmd instances. Start PowerShell/cmd again as administrator and things seem to work.

    This can happen if you're doing react-native and the node.js cmd is open in the background.

    0 讨论(0)
  • 2020-12-02 06:55

    I was already running the Node Command Window as Administrator. As mentioned by many above, the following command with --f (force) solved my issue.

    npm cache clean -f

    After the Cache Clean, the install was flawless. See the screenshot for reference

    0 讨论(0)
  • 2020-12-02 06:55

    On windows 10, npm cache clean --force and npm cache verify did not work for me. Tried to delete cache folder and file with administrator permission, did not work. The process-explorer tool helped me finding that Node.exe is holding on the cache file. I killed the process and tried to clean, worked.

    0 讨论(0)
  • 2020-12-02 06:56

    Also remember to end all other npm commands e.g. npm run dev-server.

    0 讨论(0)
  • 2020-12-02 06:57

    I messed with this problem 2 times and tried all suggestions here with mediocre success.

    • First time I tried (and succeeded luckily) by:

      1. delete the node_modules folder in your project

      2. npm clean cache -f

      3. check your %APPDATA%/npm-cache and delete everything if not empty

      4. start the terminal as administrator (in my opinion, it isnt a problem of rights, but it wont hurt if you do so)

      5. npm install and then npm update

      6. you will get errors, just install every module that throws an error manually and step by step try to eliminate everything whats wrong

    However, this method is quite frustrating and not working everytime. So try this:

    • Second time I had no luck with the steps above, so I tried to completely reinstall npm and it failed. So I thought there must something be wrong with my node.js installation. My team is running 6.10. and I had the 6.11. and tried it with the 6.10. with no luck.

      1. So I completely wiped everything off my system. Deleted all node modules, checked every path where node or npm could be and cleaned my system.

      2. Then I installed newest 8.1.3

      3. Deleted my project and cloned it to a complete different directory.

      4. Now I installed and updated everything with npm install npm update

      5. Then I compiled with just 2 modules missing and installed them manually

    Tadaaaaa, its working now. So all in all it was a problem with node.js. I recommend to everyone who runs into this problem: Try different node versions! And clean ABSOLUTE everything.

    0 讨论(0)
提交回复
热议问题