---
title: "@push.rocks/smartdeno"
---
# @push.rocks/smartdeno
a module to run deno from node

## Install

To install `@push.rocks/smartdeno`, run the following command in your project directory:

```bash
npm install @push.rocks/smartdeno --save
```

## Usage

This guide will provide an overview of how to use `@push.rocks/smartdeno` in your Node.js project to run Deno scripts. Given the nature of the project, which allows running Deno from Node.js environments, we'll explore various scenarios including setup, executing a simple Deno script, integrating with existing Node.js workflows, and managing Deno downloads.

### Setting Up

First, ensure you import `SmartDeno` in your TypeScript file using the ESM syntax:

```typescript
import { SmartDeno } from '@push.rocks/smartdeno';
```

#### Initializing SmartDeno

To start working with Deno in your Node.js project, you first need to create an instance of `SmartDeno` and start it. This process prepares the environment, including downloading Deno if necessary:

```typescript
const smartDeno = new SmartDeno();

async function setup() {
  await smartDeno.start({
    forceLocalDeno: true // Use this to force a local download of Deno even if it's globally available
  });
}

setup();
```

### Executing a Deno Script

With `SmartDeno` set and started, you can now execute Deno scripts. Let's run a simple script that prints a message:

```typescript
async function runDenoScript() {
  const script = `console.log("Hello from Deno!");`;
  await smartDeno.executeScript(script);
}

runDenoScript();
```

This method sends the script to Deno for execution. The flexibility of `SmartDeno` allows for more complex scripts to be executed similarly.

### Integrating with Node.js Workflows

`SmartDeno` can be seamlessly integrated into existing Node.js applications or workflows. Here's an example of integrating a Deno script execution within a Node.js Express server:

```typescript
import express from 'express';
const app = express();
const port = 3000;

app.get('/run-deno-script', async (req, res) => {
  const script = `console.log("Deno script executed!");`;
  await smartDeno.executeScript(script);
  res.send('Deno script executed. Check console for output.');
});

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`);
});
```

### Managing Deno Version

To manage which Deno version `SmartDeno` uses, the setup step allows for specifying `forceLocalDeno`. If you need to use a specific version of Deno, you can customize the download process by extending or modifying the download logic in `classes.denodownloader.ts`.

### Stopping SmartDeno

When your application is done using Deno, or if you need to clean up resources, you can stop the `SmartDeno` instance:

```typescript
async function teardown() {
  await smartDeno.stop();
}

teardown();
```

### Conclusion

`@push.rocks/smartdeno` provides a powerful and simple pathway for Node.js applications to run Deno scripts, combine the strengths of both environments, and leverage Deno's features within Node.js projects. Whether it's for executing isolated scripts, taking advantage of Deno's security model, or using Deno modules, `SmartDeno` offers the tools necessary for seamless integration.

For further information and advanced use cases, refer to the official GitHub repository and the typed documentation linked at the top of this guide.

## License and Legal Information

This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. 

**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

### Trademarks

This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.

### Company Information

Task Venture Capital GmbH  
Registered at District court Bremen HRB 35230 HB, Germany

For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.

By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
