Patrones de diseño en Node.js

1

Qué es Node.js y cómo impulsa tu negocio

2

Patrones de diseño esenciales en Node.js

3

Patrón Singleton y Factory en JavaScript

4

Implementación práctica de Singleton y Factory en JavaScript

5

Implementación del patrón Observer con EventEmitter en Node.js

6

Implementación de Middlewares en Node.js sin Express

7

Decorators e inyección de dependencias en JavaScript

Flujo de Datos con Node.js

8

Aprende qué son Buffer y Streams en Node.js

9

Cómo utilizar streams y pipelines en Node.js

10

Cómo funciona el Event Loop en Node.js

11

Qué es Libuv y cómo maneja la asincronía en Node.js

12

Estrategias para ejecutar código asíncrono en Node.js

Debugging y Diagnóstico en Node.js

13

Cómo utilizar el Debugger en Node.js para solucionar problemas

14

Uso de Diagnostic Channels en Node.js para observabilidad y diagnóstico

15

Instrumentación y métricas clave en performance para aplicaciones Node.js

16

Control de errores globales y manejo de señales en Node.js

17

Implementación Eficiente de Logs con Pino en Node.js

Performance en Node.js

18

Análisis del event loop en aplicaciones Node.js usando Nsolid

19

Cómo Diagnosticar y Solucionar Memory Leaks en Aplicaciones Node.js

20

Optimizar rendimiento en Node.js con Worker Threads y Child Processes

21

Optimiza y Escala Aplicaciones Node.js con Técnicas de Caching

Creando CLIs con Node.js

22

Cómo crear aplicaciones CLI con Node.js

23

Cómo Crear un CLI con Minimist y Manejar Argumentos en Node.js

24

Creación de un CLI con Node.js y Google Generative AI

25

Creación de Chat con IA usando CLI en Node

26

Cómo Crear e Instalar tu Propio CLI de Node con npm

You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

0 Días
12 Hrs
41 Min
31 Seg

Cómo Crear e Instalar tu Propio CLI de Node con npm

26/26
Resources

Creating your own command line interface(CLI) in Node.js and being able to use it from anywhere in the system provides agility and efficiency to your workflow. Learn the key steps to transform your CLI into a binary and easily install it on your machine using npm.

How to define the binary in the package.json file?

Essentially, the first thing is to edit your package.json file. Here, after the existing scripts section, you will add a new section called bin. This section will explicitly specify the name of the command and the file it will execute when invoked.

Be sure to follow these steps:

  • Add the bin section.
  • Choose a simple, clear name for your command, such as platzi-assistant.
  • Point the command to the file to be executed, for example ai-assistant.
  • Be sure to copy and paste exactly the name of the file to avoid errors.

Your package.json file should look similar to this:

{  "bin":  {    "platzi-assistant": "ai-assistant"   }}

How to install and use your CLI locally with npm link?

Once you have configured your package.json file, you are ready to install your CLI locally, for which you will use the npm link command.

Follow these simple steps:

  • Make sure you are in the directory that contains your package.json file.
  • Run in your terminal:
npm link

After running this command, you will be able to use platzi-assistant from anywhere in your terminal without needing to be in a specific directory.

Don't forget that if your CLI requires an API key, such as the one mentioned for Gemini, you must make sure to set it before use.

Why publish your CLI in npm and how to do it?

Publishing your CLI package in npm allows you to use it globally or run it easily with npx without prior installations. You can install globally published packages by:

npm install -g package-name

Or run them temporarily without installation using the npx command:

npx package-name

Exploring npm publishing can take the usability of your creations to another level. Consider checking out the specialized npm publishing course Platzi has available if you want to delve deeper into these topics.

Do you have creative ideas for useful CLI commands that you can develop? Share them in comments and encourage others to use them and contribute!

Contributions 0

Questions 0

Sort by:

Want to see more contributions, questions and answers from the community?