How to uninstall global package with npm?

后端 未结 5 1583
难免孤独
难免孤独 2020-12-15 03:28

I have installed webpack in this way:

npm install -g webpack

Now want to uninstall it:

npm uninstall -g webpack


        
相关标签:
5条回答
  • 2020-12-15 03:36

    You have to remove the packages manually installed globally on your os with sudo:

    On OsX navigate to this directory

    cd /usr/local/lib/node_modules
    

    and

    sudo rm -rf <packageName> // sudo rm -rf webpack
    
    0 讨论(0)
  • 2020-12-15 03:40

    You're most likely running a file from another install of npm.

    Run which webpack to see where your shell is finding webpack.

    Run npm root -g to find the root of the tree it's supposed to be in, being sure you're running the correct npm with npm -v and which npm.

    If your webpack bin isn't in the npm root, reset your path to the webpack binary e.g. hash -d webpack in bash, and then go remove the unwanted npm root from your PATH variable. You can now use npm install -g webpack and npm uninstall -g webpack and it should work.

    0 讨论(0)
  • 2020-12-15 03:47

    Try running both the below:

    npm uninstall -g webpack
    npm uninstall webpack
    

    I think you might be checking/lloking at the local version after deleting only the global one.

    0 讨论(0)
  • 2020-12-15 03:48

    Try

    chown -R "$(whoami)": "$(npm root -g)" 
    

    (you may need sudo for it) and then npm uninstall -g again

    0 讨论(0)
  • 2020-12-15 03:57
    npm uninstall -g webpack
    

    Worked for me, try running the command prompt in administrator mode.

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