Make the MongoDB docs better! We value your opinion. Share your feedback for a chance to win $100.
Click here >
Docs Menu
Docs Home
/ /
SDK de Dispositivo Atlas

Install the Node.js SDK

El Atlas Device SDK para Node.js permite el desarrollo de aplicaciones utilizando los lenguajes JavaScript y TypeScript. El SDK de Node.js es más apto para escribir aplicaciones del lado del servidor. Tu aplicación Node.js puede ser un componente en una pila más amplia que también incluya aplicaciones iOS y Android.

The Node.js SDK is not suitable for front-end application development.

  • Due to limitations of the browser environment, it is not possible to build a browser-based web app with this SDK. For front-end web applications, use the Web SDK.

  • Para el desarrollo de aplicaciones móviles multiplataforma, use el SDK de React Native.

Before getting started, ensure your environment meets the following prerequisites:

  • Node.js versión 12.x o posterior (incluida la versión 14 de Node.js)

  • Linux, macOS 10.8 (o posterior) o Windows 8 (o posterior)

Follow these steps to create a Node.js project and add the Node.js SDK to it.

Tip

Atlas Device SDK and Realm

The SDK uses Realm Core database for device data persistence. When you install the Node.js SDK, the package names reflect Realm naming.

1

Cree su proyecto Node.js creando un nuevo directorio para su proyecto y ejecutando npm init En ese directorio. En el ejemplo a continuación, reemplaza MyApp con el nombre del proyecto que desees. Responde a todas las preguntas para completar los detalles de tu proyecto.

mkdir MyApp && cd MyApp && npm init
2

In your Node.js project directory, use the following command to add the SDK to your project:

npm install realm@12
3

TypeScript is a superset of JavaScript that adds static type checking and other features intended to make application-scale development more robust. If you'd like to use TypeScript, follow the TypeScript team's official Node Starter guide. The SDK supports TypeScript natively and integrates easily into a TypeScript project.

Tip

Atlas Device SDK and Realm

The SDK uses Realm Core database for device data persistence. When you install the Node.js SDK, the package names reflect Realm naming.

To create a Node.js project and add the Node.js SDK on an Internet of Things (IoT) platform such as the Raspberry Pi 2, 3, or 4 running Raspberry Pi OS (formerly Raspbian), follow the steps below:

1

The Node.js SDK's IoT library is not distributed as a binary, so you must build it from source. To do this, you'll need a working C++ compiler. To install such a compiler on your IoT device, run the following command:

sudo apt install build-essential g++ libssl-dev
2

Crea tu proyecto Node.js creando un nuevo directorio para tu proyecto y ejecutando npm init en ese directorio. En el siguiente ejemplo, reemplace MyApp por el nombre de proyecto deseado. Responde a todos los indicios para rellenar los detalles de tu proyecto.

mkdir MyApp && cd MyApp && npm init
3

In your Node.js project directory, use the following command to add the SDK to your project:

npm install realm@12
4

TypeScript is a superset of JavaScript that adds static type checking and other features intended to make application-scale development more robust. If you'd like to use TypeScript, follow the TypeScript team's official Node Starter guide. The SDK supports TypeScript natively and integrates easily into a TypeScript project.

Add the following line to the top of your source files (JavaScript or TypeScript) where you want to use the SDK:

import Realm from "realm";

Next

Bienvenido a la Docs de Atlas Device SDK

En esta página