> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.bearsampp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js in Bearsampp: Versions and npm Usage

> Run Node.js scripts and npm commands in Bearsampp without a separate Node.js install. Switch versions and open an npm-ready console from the tray menu.

Bearsampp includes Node.js so you can run JavaScript on the server side, use npm to manage packages, and run build tools like Webpack or Vite — all without installing Node.js separately on your machine. Node.js is a standalone tool in Bearsampp rather than a Windows service, which means it does not start or stop in the background; it runs only when you invoke it directly.

## What is included

Each Node.js version in Bearsampp bundles:

* The `node` executable
* `npm` (Node Package Manager)
* An `npmrc` configuration file for npm settings

## Opening the Node.js console

The fastest way to run Node.js commands in Bearsampp is through the built-in console, which launches a command prompt with Node.js and npm already on the `PATH`:

<Steps>
  <Step title="Open the Node.js console">
    Right-click the tray icon → **Node.js** → **Console**.
  </Step>

  <Step title="Run your commands">
    Type `node --version` to confirm the active version, then run any `node` or `npm` command you need.
  </Step>
</Steps>

<Tip>
  You can also use the **Git console** (tray → **Git** → **Git console**) to run npm commands. It has Node.js on its `PATH` as well, and it gives you Git integration in the same window.
</Tip>

## Switching Node.js versions

Bearsampp supports multiple Node.js versions. To switch:

<Steps>
  <Step title="Open the versions menu">
    Right-click the tray icon → **Node.js** → **Versions**.
  </Step>

  <Step title="Select a version">
    Click the version you need. Bearsampp updates the active Node.js symlink so any new console you open uses the selected version.
  </Step>
</Steps>

<Note>
  Switching the Node.js version does not affect any already-open console windows. Close and reopen the console after switching to pick up the new version.
</Note>

## npm configuration

npm reads its configuration from the `npmrc` file bundled with each Node.js version:

```
bin/nodejs/nodejsX.X.X/etc/npmrc
```

You can also use a project-level `.npmrc` file in your project root, or a user-level one at `~/.npmrc`. npm merges settings from all three locations.

## Running Node.js scripts

You can run any Node.js script from the console or integrate Node.js into your project workflow:

```bash theme={null}
node app.js
```

```bash theme={null}
npm install
npm run build
npm start
```

If your project has a `package.json`, run `npm install` first to install dependencies, then use whichever `npm run` scripts your project defines.

## Common use cases

<CardGroup cols={2}>
  <Card title="Install a package globally" icon="box">
    Open the Node.js console and run `npm install -g package-name`.
  </Card>

  <Card title="Run a build tool" icon="hammer">
    Navigate to your project folder and run `npm run build` or `npx webpack`.
  </Card>

  <Card title="Start a dev server" icon="server">
    Run `npm run dev` or `node server.js` to start a local Node.js HTTP server.
  </Card>

  <Card title="Manage dependencies" icon="list">
    Use `npm install`, `npm update`, and `npm uninstall` to manage your project's `node_modules`.
  </Card>
</CardGroup>

## Module details

| Property       | Value                              |
| -------------- | ---------------------------------- |
| Type           | Tool (not a Windows service)       |
| npm            | Bundled with each Node.js version  |
| Config file    | `bin/nodejs/nodejsX.X.X/etc/npmrc` |
| Version switch | Tray → Node.js → Versions          |
| Console access | Tray → Node.js → Console           |
