# Node Polyfills

### 1) Require is not a function

this usually happens when working with [vite](https://vitejs.dev/) bundler. This config fixes it:

**vite.config.ts**

```typescript
export default defineConfig({
    ...
    build: {
        commonjsOptions: {
            transformMixedEsModules: true,
        },
    }
    ...
})
```

### 2) \[crypto, http, https, stream, etc...] module not found

you miss some node polyfills, the fix depends on the bundler

example for vite bundler using \`vite-plugin-node-polyfills\`:

**vite.config.ts**

```typescript
import { nodePolyfills } from 'vite-plugin-node-polyfills';

export default defineConfig({
    plugins: [nodePolyfills()],
    ...
})
```

### 3) Can't find variable \[Buffer, process, global]

it's a common issue when you miss other node polyfills.\
in Angular we fixed it like so:

**src/polyfills.ts**

```typescript
(window as any).global = window;
global.Buffer = global.Buffer || require('buffer').Buffer;
(window as any).process = {
    env: { DEBUG: undefined },
    version: '', // to avoid undefined.slice error
};
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vechain.org/developer-resources/sdks-and-providers/dapp-kit/dapp-kit-1/node-polyfills.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
