Error “Cannot find module 'npmlog'” after “npm update -g”

前端 未结 9 1230
轻奢々
轻奢々 2020-12-20 11:35

I have NVM 0.30.1 and used it to install node.js v5.4.0 (with NPM 3.5.4) on Fedora 22. When I run npm update -g, I receive the following warnings:



        
相关标签:
9条回答
  • 2020-12-20 11:43

    There is an option to bump npm without reinstalling node.

    #### # this will remove current npm
    rm -rf /usr/local/lib/node_modules/npm/
    
    #### # install npm from sources. Version 3.5.x will be installed
    apt-get update
    apt-get install npm
    
    #### # install the newest npm version. Bumping from 3.5.X to 6.14.X goes without any issue :)
    /usr/bin/npm install npm@latest -g
    
    #### # additionally, npm with version 3.5.x is not added to $PATH, so it's not used.
    
    0 讨论(0)
  • 2020-12-20 11:50

    Thanks for the answers. It was a bug and it has already been fixed in Node v5.4.1. Now it's working as usual.

    0 讨论(0)
  • 2020-12-20 11:50

    Some of the answers already answered the question, but I will still like to throw in my own idea. I encountered same issue after I was told to run npm update -g npm after running that piece of code, the error started. I solved mine by using Node Version Manager(nvm):

    nvm install 8
    

    Note: not actually 8, but to a version of your choice e.g(6,5). Writing the version number will automatically install the stable of the version specified. After the installation you should get a CLI message:

    Now using node v8.11.4 (npm v5.6.0) 
    
    0 讨论(0)
  • 2020-12-20 11:52

    It looks like npm update -g cannot update npm to the newest version. I solve the problem by updating npm installation manually.

    1. Install/ reinstall node to get the bundled npm
    2. run npm install -g npm@3.5.4 to update the global npm installation
    3. now npm update -g should work
    0 讨论(0)
  • 2020-12-20 11:54

    I have faced the same issue in my Windows 10 PC. After looking into solutions, since i couldn't find the exact solution for the issue i was facing Cannot find module 'npmlog' I just uninstalled the node js and then, deleted both 'npm' and 'npm-cache' in "C:\Users\YourPCName\AppData\Roaming"

    Then, i downloaded the latest version of node from Node JS Website

    And, installed node js

    After that i checked with the path in environment variables.

    Finally run the command prompt 'run as administrator' and npm install npm -g

    Checking your version will show the latest version. 'npm -v'

    I got the latest version - v3.10.9

    Try this. this should work.

    0 讨论(0)
  • 2020-12-20 11:56

    What fixed this for me was

    sudo rm -rf /usr/local/lib/node_modules/
    

    and then re-installing node (with npm).

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