Sha256: 67af513759547ec985bc967517b779db11af99408aed53d8caa60886e658b35c

Contents?: true

Size: 1.35 KB

Versions: 22

Compression:

Stored size: 1.35 KB

Contents

---
title: About the npm Resource
platform: os
---

# npm

Use the `npm` InSpec audit resource to test if a global NPM package is installed. NPM is the the package manager for Node.js packages (https://docs.npmjs.com), such as Bower and StatsD.

<br>

## Syntax

A `npm` resource block declares a package and (optionally) a package version:

    describe npm('npm_package_name') do
      it { should be_installed }
    end

where

* `('npm_package_name')` must specify an NPM package, such as `'bower'` or `'statsd'`
* `be_installed` is a valid matcher for this resource

<br>

## Examples

The following examples show how to use this InSpec audit resource.

### Verify that bower is installed, with a specific version

    describe npm('bower') do
      it { should be_installed }
      its('version') { should eq '1.4.1' }
    end

### Verify that statsd is not installed

    describe npm('statsd') do
      it { should_not be_installed }
    end

<br>

## Matchers

For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).

### be_installed

The `be_installed` matcher tests if the named Gem package and package version (if specified) is installed:

    it { should be_installed }

### version

The `version` matcher tests if the named package version is on the system:

    its('version') { should eq '1.2.3' }

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
inspec-core-2.1.84 docs/resources/npm.md.erb
inspec-2.1.84 docs/resources/npm.md.erb
inspec-core-2.1.83 docs/resources/npm.md.erb
inspec-2.1.83 docs/resources/npm.md.erb
inspec-core-2.1.81 docs/resources/npm.md.erb
inspec-core-2.1.80 docs/resources/npm.md.erb
inspec-2.1.80 docs/resources/npm.md.erb
inspec-core-2.1.78 docs/resources/npm.md.erb
inspec-2.1.78 docs/resources/npm.md.erb
inspec-core-2.1.72 docs/resources/npm.md.erb
inspec-2.1.72 docs/resources/npm.md.erb
inspec-core-2.1.68 docs/resources/npm.md.erb
inspec-2.1.68 docs/resources/npm.md.erb
inspec-core-2.1.67 docs/resources/npm.md.erb
inspec-2.1.67 docs/resources/npm.md.erb
inspec-2.1.59 docs/resources/npm.md.erb
inspec-2.1.54 docs/resources/npm.md.erb
inspec-2.1.43 docs/resources/npm.md.erb
inspec-2.1.30 docs/resources/npm.md.erb
inspec-2.1.0 docs/resources/npm.md.erb