npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

scrap-mechanic-common

v1.2.3

Published

Things commonly used when working with Scrap Mechanic

Readme

scrap-mechanic-common

Things commonly used when working with Scrap Mechanic

PathHelper

Handles finding the game installation and user directories

const { PathHelper } = require("scrap-mechanic-common");

// Locate the User_012345678 directory in %appdata%
PathHelper.findUserDir();

(async () => {
    
    if (await PathHelper.findSMInstallDir()) {
        // Found the game installation directory
        
        // Update GAME_DATA, SURVIVAL_DATA and CHALLENGE_DATA from PathHelper
        // to use the new PathHelper.INSTALLATION_DIR value
        PathHelper.updatePaths();
        
        // Expands $GAME_DATA, $SURVIVAL_DATA and $CHALLENGE_DATA to their full locations
        let texture = "$GAME_DATA/Objects/Textures/Blocks/blk_woodplanks01_dif.tga";
        console.log("Wood texture location:", PathHelper.expandPathPlaceholders(texture));
    } else {
        // Unable to locate the game installation directory
    }
    
})();

With Electron

If the game was unable to be found the user is able to select the correct installation directory themselves.

const { app  } = require("electron");
const { PathHelper } = require("scrap-mechanic-common");

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on("ready", async (event, launchInfo) => {

    // First tries to find it automatically. If it fails, opens a dialog
    // and lets the user select it manually
    if (await PathHelper.findOrSelectSMInstallDir()) {
        // User has selected a valid Scrap Mechanic installation directory
    
        // Update GAME_DATA, SURVIVAL_DATA and CHALLENGE_DATA from PathHelper
        // to use the new PathHelper.INSTALLATION_DIR value
        PathHelper.updatePaths();
    
        // Locate the User_012345678 directory in %appdata%
        PathHelper.findUserDir();
        
        // Continue the app
        createWindow();
    } else {
        // User canceled the selection
        
        app.quit();
    }
});

WorkshopModManager

Handles installed workshop mods.

const { PathHelper, WorkshopModManager } = require("scrap-mechanic-common");

(async () => {
    // Find PathHelper.USER_MODS_DIR
    PathHelper.findUserDir();
    
    // Find PathHelper.WORKSHOP_DIR
    if (await PathHelper.findSMInstallDir())
        PathHelper.updatePaths();

    // Loads all mods found in WorkshopModManager.getModsDirectories() and parses the shapesets
    let { modCount, shapeCount } = WorkshopModManager.reloadMods(true /* parse shapesets */);
    console.log(`Loaded ${modCount} mods with ${shapeCount} shapes`);
    
    // All loaded mods, including fake mods for Creative, Survival and Challenge mode
    console.log("The mod is called:", WorkshopModManager.mods["26ef623b-97d2-49ba-9a10-8898c1a94e9a"].name);
    
    // Gets the mods that have a shape with the uuid of Wood Block 1
    WorkshopModManager.getModsWithShapeUuid("df953d9c-234f-4ac2-af5e-f0490b223e71")
    
    // Expands $CONTENT_${mod.localId} to the full path
    let preview = "$CONTENT_26ef623b-97d2-49ba-9a10-8898c1a94e9a/preview.jpg";
    console.log("The The Modpack mod preview image can be found in:", WorkshopModManager.expandPathPlaceholders(preview));
    
})();