DEV Community

Charan Gutti
Charan Gutti

Posted on

How to Build, Test, and Check Your Own SDK Locally (Beginner-Friendly) in Javascript

Building your own SDK (Software Development Kit) may sound complicated, but trust me—it’s actually simple. In this guide, we’ll walk through step by step how to:

  1. Build a small SDK.
  2. Test it in another project.
  3. Check which packages are installed.

And yes, we’ll keep it beginner-friendly with visuals. 🚀


🏗️ 1. Create the Project Structure

First, make a new folder called my-sdk.
Inside it, create two files:

my-sdk/
├── package.json
└── my-sdk.js
Enter fullscreen mode Exit fullscreen mode

File 1: package.json

{
  "name": "my-sdk",
  "version": "1.0.0",
  "main": "my-sdk.js"
}
Enter fullscreen mode Exit fullscreen mode

File 2: my-sdk.js

function sayHello() {
    return _internalHello();
}

function _internalHello() {
    return "Hello, World!";
}

module.exports = { sayHello };
Enter fullscreen mode Exit fullscreen mode

👉 package.json tells Node.js about your SDK (name, version, entry point).
👉 my-sdk.js is the logic—here, it just returns “Hello, World!”.


🔗 2. Install the SDK Locally

Open a terminal inside the my-sdk folder and run:

npm link
Enter fullscreen mode Exit fullscreen mode

This command makes your SDK available globally on your computer.
Think of it like: “Hey npm, please remember this package everywhere.”


🧪 3. Create a Test Project

Now, let’s test your SDK.

Create a different folder (e.g., test-project) and add a file called test.js:

test-project/
└── test.js
Enter fullscreen mode Exit fullscreen mode

File: test.js

const { sayHello } = require('my-sdk'); // Import your SDK

const message = sayHello();
console.log(message);
Enter fullscreen mode Exit fullscreen mode

▶️ 4. Link and Run the Test

Inside the test-project folder, run:

# Link your local SDK here
npm link my-sdk

# Run the test
node test.js
Enter fullscreen mode Exit fullscreen mode

✅ You should see:

Hello, World!
Enter fullscreen mode Exit fullscreen mode

🎉 Congrats! You just created and tested your very own SDK locally.


📦 5. How to See Installed Packages

Perfect question! After creating and testing your SDK, you might wonder:
“Which packages are installed right now?”

There are two main ways:


1. See ALL Packages Installed on Your Machine (Global)

Run this in any terminal:

npm list -g --depth=0
Enter fullscreen mode Exit fullscreen mode
  • -g = global packages (available everywhere).
  • --depth=0 = shows only top-level packages (not their dependencies).

2. See Packages for a Specific Project (Local)

Go to your project folder (the one with package.json) and run:

npm list --depth=0
Enter fullscreen mode Exit fullscreen mode

Example output:

my-test-project@1.0.0 /path/to/project
├── my-sdk@1.0.0
└── express@4.18.2
Enter fullscreen mode Exit fullscreen mode

👉 This tells you your project depends on my-sdk and express.


🖼️ Visual Flow

Here’s the big picture:

[ my-sdk ] --npm link--> [ global npm space ] --npm link my-sdk--> [ test-project ]
Enter fullscreen mode Exit fullscreen mode

So the flow is:

  1. Build your SDK (my-sdk).
  2. Link it globally (npm link).
  3. Connect it to your test project (npm link my-sdk).
  4. Run your test file (node test.js).

💡 Why This is Useful

  • You can develop faster without publishing to npm every time.
  • Any change in my-sdk.js reflects immediately in your test project.
  • You can easily check installed packages (global or local).

That’s it! You now know how to build, test, and inspect SDKs locally like a pro. 🚀

Top comments (0)