node.jsgruntjsnpm

How to tell if an npm package was installed globally or locally


I am installing Grunt, Node.js, npm, Bower, and grunt-cli on Windows 7.

The instructions say I should run the install commands with the -g flag for global.

How can I check if I used the -g flag when I installed? It will take a lot of time to uninstall them and reinstall.


Solution

  • Use the list command with the -g flag to see all packages that are installed globally:

    npm list -g

    To check if a specific package is installed globally, you can provide the name of package (grunt in this case) as seen below:

    npm list -g grunt

    Or you can use grep to filter on package names:

    npm list -g | grep grunt

    Source: https://docs.npmjs.com/cli/ls