Usually you install NPM modules globally if you want them included in your path to be ran from the command line. Since it is installed locally you will have to run it from the node_modules folder.
npm packages can be installed globally using the -g or --global flag so that the package can be used from the console.
You can install a package locally if you want to depend on the package from your own module, using something like Node. js require . This is npm install 's default behavior.
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
npm list --depth 1 --global packagename > /dev/null 2>&1
You can then check the exit status to see if it's installed or not. Thanks Adam Monsen.
To check if a specific package is installed globally execute:
npm list -g [package-name]
Let's take "grunt" as an example. If it is installed globally, you should see something like this
C:\data\tryout\test1>npm list -g grunt
C:\Users\xxxxxxx\AppData\Roaming\npm
└── [email protected]
If it is not installed globally, you should see something like this
C:\data\tryout\test1>npm list -g grunt
C:\Users\xxxxxxx\AppData\Roaming\npm
└── (empty)
To check if a specific package is installed locally you can execute the same commands as above but without the -g parameter.
source: How to check if npm package was installed globally or locally.
You can list all global packages with the command:
npm ls -g
Or check for a specific package with:
npm ls -g [package-name]
For example: npm ls -g @angular/cli
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With