Introducci贸n a Node.js
Introducci贸n Node.js
Instalaci贸n y configuraci贸n del entorno de Node.js
Primer proyecto con Node.js
Quiz: Introducci贸n a Node.js
M贸dulos y gesti贸n de paquetes
Tipos de M贸dulos en Node.js
Gesti贸n de Paquetes con NPM
Creaci贸n de un Paquetes con NPM
Publicaci贸n de Paquetes con NPM
Quiz: M贸dulos y gesti贸n de paquetes
M贸dulos nativos en Node.js
Introducci贸n al M贸dulo FS de Node.js
Leer y escribir archivos en Node.js
M贸dulo fs: Implementar transcripci贸n de audio con OpenAI
M贸dulo Console: info, warn, error, table
M贸dulo Console: group, assert, clear, trace
M贸dulo OS: informaci贸n del sistema operativo en Node.js
M贸dulo Crypto: cifrado y seguridad en Node.js
M贸dulo Process: manejo de procesos en Node.js
Timers: setTimeout, setInterval en Node.js
Streams: manejo de datos en tiempo real en Node.js
Buffers: manipulaci贸n de datos binarios en Node.js
Quiz: M贸dulos nativos en Node.js
Servidores con Node.js
HTTP: fundamentos de servidores en Node.js
Servidor nativo y streaming de video en Node.js
You don't have access to this class
Keep learning! Join and start boosting your career
Package management with NPM is a fundamental skill for any modern JavaScript developer. This system not only makes it easy to incorporate third-party code into our projects, but also allows us to share our own creations with the global community of developers, thus fostering a collaborative and efficient ecosystem.
NPM (Node Package Manager) is the tool that allows us to install, uninstall and manage the packages that the community builds in order to incorporate them into our projects. It works as a huge library of resources that facilitates the development, avoiding us to "reinvent the wheel" constantly.
The npmjs.com website is the central point where we can find this vast collection of resources. From simple validators to complete frameworks, practically any functionality we need probably already exists as an NPM package.
Most of these packages are open source, which means we can:
NPM is installed by default when we install Node.js on our system. We can verify its presence and version with a simple command:
npm -v
To initialize a project with NPM, we must run:
npm init
This command starts an interactive process that will ask us for information to configure our project:
All this information will be stored in a file called package.json, which will function as the central configuration of our project.
Once our project is initialized, we can start installing packages. For example, if we want to install a package to validate if a value is numeric:
npm install is-number# or for shortnpm i is-number.
This command performs several important actions:
Once installed, we can use the package in our code:
const isNumber = require('is-number');
console.log(isNumber(5)); // trueconsole.log(isNumber('hello')); // false
The node_modules folder can become extremely large, as it contains all installed packages and their dependencies. For this reason, it is standard practice to exclude it from our Git repository.
To do this, we create a .gitignore file in the root of our project. We can use tools like gitignore.io to generate a file suitable for Node.js projects.
NPM allows us to define scripts in our package.json to execute frequent tasks:
"scripts": { " start": "node main.js"}
These scripts can be run with:
npm run start
Scripts are a powerful way to standardize commands that are frequently used in the development, testing or deployment of our applications.
NPM is a fundamental tool in the JavaScript ecosystem that greatly facilitates the development of modern applications. Mastering its use will allow you to take advantage of the work of thousands of developers and contribute your own creations to this vibrant community. Have you created a package for NPM or do you have any questions about how to implement one in particular? Share your experience in the comments!
Contributions 0
Questions 1
Want to see more contributions, questions and answers from the community?