Harness the Combinatoric Power of Command-Line Tools and Utilities

../Tutorials

Manage Project Dependencies with Mise

Bash Windows Linux macOS Tools

Published July 11, 2025 and last verified on July 11, 2025

Mise gives you a single tool to manage your development environment, from the programming language you use and environment variables you set, to the tasks you run. Think of it like combining make, direnv, and a version manager like nvm or rvm. Rather than juggling multiple configuration files and tools, you use one tool with a configuration file for everything.

To demonstrate, you’ll use Mise to manage the dependencies and environment for a small Node.js project that talks to OpenAI and feeds it a page to summarize and create a description that search engines can use. When you’re done you’ll have a working AI summarizing utility with a managed development environment.

What You Need

To follow along, you will need:

  • An OpenAI API key and some credits added to your account.
  • On macOS, you’ll need Homebrew installed, which you can do by following the Install Homebrew tutorial.

Installing Mise and Setting Up Your Project

As mentioned in the introduction, you’re going to use Mise to manage the environment for a small Node.js application. This means you’ll manage Node.js, its dependencies, and environment variables.

To install Mise on macOS, use Homebrew:

brew install mise

On Windows using Winget, install with:

winget install jdx.mise

Or use Chocolatey:

choco install mise

For Linux machines, see the official Getting Started page to find instructions for your platform.

With Mise installed, create a directory to hold your summarization project, and switch to that directory:

mkdir seo-summary-cli && cd seo-summary-cli

Now tell Mise to use Node.js version 20 for this project with the following command:

mise use node@20

Mise downloads and installs Node.js 20:

gpg: Signature made Tue Apr 22 05:30:48 2025 CDT
gpg:                using RSA key A6023530FC53461FEC91F99C04CD3F2FDE079578
gpg: Good signature from "ulises Gascon <ulisesgascongonzalez@gmail.com>" [unknown]
mise node@20.19.1 ✓ installed                                                                                                                                                                                         mise ~seo-

Confirm Node.js 20 is available by using the mise exec command:

$ mise exec -- node -v

Using mise exec runs commands under the Mise environment.

Now create a package.json file for your project using npm init, but use mise exec to ensure it uses the Node.js version you installed with Mise:

$ mise exec -- npm init -y

Now install the necessary dependencies, again using mise exec with npm. You’ll use the OpenAI package to talk to OpenAI’s API and the Cheerio package to parse HTML:

$ mise exec -- npm install cheerio openai

You now have your project and dependencies configured. Next you’ll manage environment variables.

Managing Secrets

Your application will use OpenAI’s API to process your request. It’s common to store this and other secrets in environment variables. The common development practice is to use an environment file to hold these variables and then use a tool to load them into the environment when the application runs. Mise can handle this for you..

Add your OpenAI key to a .env file:

echo 'OPENAI_API_KEY=your-api-key-here' > .env

Now open the file mise.toml and add this section to load that file:

[env]
_.file = '.env'

Now you don’t need another third-party tool or Node.js package to manage the environment variable. Make sure you ignore the .env file you created so you don’t check your key into GitHub.

Check your environment to ensure the key exists:

mise env

Your key prints to the screen. You’re now ready to write the code for this project.

Building the Application

Create the app that grabs the page and sends it to OpenAI for summarization. Create the file seo-summary.js and add the following code:

#!/usr/bin/env node
const cheerio = require('cheerio');
const { OpenAI } = require('openai');

const url = process.argv[2];
if (!url) {
  console.error('Usage: node seo-summary.js <url>');
  process.exit(1);
}

(async () => {
  try {
    // Fetch page content
    const response = await fetch(url);
    const html = await response.text();

    // Parse and extract text
    const $ = cheerio.load(html);
    let text = '';
    $('body *').each((_, el) => {
      const nodeText = $(el).text().trim();
      if (nodeText) text += nodeText + '\n';
    });

    // Send to OpenAI
    const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
    const result = await openai.chat.completions.create({
      model: 'gpt-4',
      messages: [
        { role: 'system', content: 'You are an expert SEO assistant.' },
        { role: 'user', content: `Summarize the following page in 160 characters or less:\n\n${text}` }
      ],
      temperature: 0.7,
    });

    console.log('\nSEO Summary:');
    console.log(result.choices[0].message.content.trim());
  } catch (err) {
    console.error('Error:', err.message);
    process.exit(1);
  }
})();

The code takes in input from the command line and creates a small chatbot with instructions and a prompt, using the OpenAI API and your key to process the request.

Save the file. You could run this with mise exec, but Mise lets you define tasks that make it easier to run commands.

Using Tasks

When you’re developing apps you’ll have tasks related to running tests, launching development servers, or even deploying your application. You can define tasks like this in the mise.toml file.

Open mise.toml and add the following code to create a new task called summarize that runs the your application:

[tasks]
summarize = "node seo-summary.js"

This runs the app under the Mise environment using your environment variables, Node.js version, and its dependencies.

Test out your task by running the mise summarize command and passing the URL you want to summarize:

$ mise summarize https://example.com

This loads up the version of Node.js, loads the environment variable, and runs the task. The URL for the site gets passed as an argument to the task, which it passes to the Node.js script. The result is a summary of the page.

Conclusion

Now that you’ve used Mise for this project, you may want to set it up with your shell so that it automatically activates the environment and tool versions when you switch to your project directory. This way you can run your commands directly instead of using mise exec when you run commands . See the documentation for instructions on how to do that with your shell of choice.

Mise gives you consistent tool, task, and environment management for your projects, regardless of programming language.