Publicar un paquete de npm tutorial

Ver Otros Cursos

Este es un ejemplo practico de Nodejs y Javascript, en el que aprenderemos a publicar un modulo de Node en, el registro de repositorio de código de Node.

843 vistas

similar to: nodemon express-generator create-react-app etc

mkdir npm-helloworld npm init -y

un src/index.js

const axios = require('axios');

const greet = name => 'Hello ' + name;

const users = async () => {
  const res = await axios.get('')


module.exports = {

you need an npm account. to add one: npm adduser

then you can go to npm and login.

npm whoami

if you have an account npm login

to see the version of our package npm version

to update the version

make sure the name of your module is unique, because it could be other packages with the smae name. so for this example i will add in package.json in the name something like: npm-helloworld-fazttest.

then: npm publish

you can go yo your npm profile and see the package sin un

Let's add a readme.

create a

# example npm package
* getUsers
* greet

npm version 1.0.2 npm publish

using your module

const {greet, users} = require('npm-helloworld-fazttest')


users().then(data => console.log(data))


upload to githb npm init -y npm version 1-0.3 npm publish