Skip to content

andres-acc/npm-break

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm - wolox break

Description

This is a repo based on a break about npm.

Steps to replicate the project

  1. initialize the npm project

npm init (inside of a folder)

package.json

  {
    "name": "number-helpers-wolox",
    "version": "1.0.0",
    "description": "Get information about an array of numbers",
    "main": "build/index.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [
      "numbers",
      "array",
      "helpers",
      "wolox"
    ],
    "author": "Andres Alcaraz",
    "license": "ISC"
  }

UPDATE MAIN PATH

commit

  1. Add libraries and typescript configuration

npm i babel-cli babel-preset-latest @babel/preset-env @types/babel__preset-env jest @types/jest watch @babel/preset-typescript --save-dev

tsc --init

config tsconfig.json:

  "rootDir": "./src",
  "moduleResolution": "node",       
  "outDir": "./build",

Create file .babelrc

  {
    "presets": [
      "@babel/preset-typescript",
      ["@babel/preset-env"]
    ]
  }

commit

  1. Add base file

In src/index.ts console.log('Hello Wolox');

node src/index.ts

  1. Add base scripts
  "test": "jest",
  "build": "tsc -p tsconfig.json",
  "dev": "watch 'npm run build' src",
  "test:watch": "npm test -- --watch"
  1. Add functionality

commit

  1. Test locally

a. Create new empty project b. From the package run > npm link c. From the new project run: > npm link name-of-package d. test functionality

  1. Publish package

Add .npmignore

  src

npm adduser npm publish

That's it, now you could install your package in any other project you want.

By Andres Alcaraz

About

This is a repo based on a break about npm.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published