Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
inspect
✓ import { inspect } from 'snyk-nuget-plugin'
✗ const inspect = require('snyk-nuget-plugin').inspect
ESM export; named import required.
buildDepTreeFromProjectJson
✓ import { buildDepTreeFromProjectJson } from 'snyk-nuget-plugin'
✗ import buildDepTreeFromProjectJson from 'snyk-nuget-plugin'
Named export, not default.
buildDepTreeFromPackagesConfig
✓ import { buildDepTreeFromPackagesConfig } from 'snyk-nuget-plugin'
✗ const { buildDepTreeFromPackagesConfig } = require('snyk-nuget-plugin')
ESM-only since v3; CJS require not supported.
buildDepTreeFromProjectAssets
✓ import { buildDepTreeFromProjectAssets } from 'snyk-nuget-plugin'
For .assets.json files.
Shows how to import the inspect function, run dotnet restore, and scan a NuGet project's assets file for vulnerabilities.
import { inspect } from 'snyk-nuget-plugin';
import { execSync } from 'child_process';
import * as fs from 'fs';
const targetFile = 'path/to/project.assets.json';
// Ensure .NET SDK is installed and restore has been run
const projectFolder = 'path/to/project';
try {
execSync('dotnet restore', { cwd: projectFolder, stdio: 'pipe' });
} catch (e) {
console.error('dotnet restore failed:', e.stderr?.toString() || e.message);
process.exit(1);
}
inspect('.', targetFile)
.then((result) => {
console.log('Scanned successfully:', result.package?.name);
console.log('Dependencies:', JSON.stringify(result.dependencyTree, null, 2));
})
.catch((err) => console.error('Inspect failed:', err));
Errors
Common errors & fixes
Error: Cannot find module 'snyk-nuget-plugin'
Package not installed or not in node_modules
fixInstall as dependency: npm install snyk-nuget-plugin
TypeError: inspect is not a function
Incorrect import: default import used instead of named import
fixUse import { inspect } from 'snyk-nuget-plugin' instead of import inspect from 'snyk-nuget-plugin' dotnet restore failed with exit code 1
dotnet restore command failed, usually due to missing .NET SDK or network issues
fixInstall .NET SDK >=6.0 and ensure internet access for NuGet restore
Audit
Dependencies
@snyk/dep-graphoptionaldependency graph construction
debugoptionaldebug logging