Prerequisites
Before you begin, ensure you have:- Node.js 18 or higher
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
The SCANOSS JS SDK provides a JavaScript module for interacting with the SCANOSS API and scanning engine directly from your JavaScript projects.
npm install scanoss
// ES module
import { Scanner, ScannerEvents, ScannerCfg } from "scanoss";
// CommonJS
const { Scanner, ScannerEvents, ScannerCfg } = require("scanoss");
// Import as ES6
import { Scanner, ScannerEvents } from "scanoss";
// Import as CommonJS
// const { Scanner, ScannerEvents } = require('scanoss');
const scanner = new Scanner();
// Set the folder path where the module will save the scan results and fingerprints
// If is not specified, the module will create a folder on tmp
// directory using a timestamp as a name
scanner.setWorkDirectory("/yourProjectFolder/ScanResults/");
// Set the scanner log event handler
scanner.on(ScannerEvents.SCANNER_LOG, (logTxt) => console.log(logTxt));
// Set the scanner finish event handler
scanner.on(ScannerEvents.SCAN_DONE, (resultPath) => {
console.log("Path to results: ", resultPath);
});
const scannerInput = {
fileList: ["/yourProjectFolder/example1.c"],
};
// Launch the scanner
scanner.scan([scannerInput]);