All Projects β†’ reggi β†’ Lerna Tutorial

reggi / Lerna Tutorial

πŸ‰ A basic description of how to use Lerna

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Lerna Tutorial

Choo Handbook
πŸš‚βœ‹πŸ“– - Learn the choo framework through a set of exercises
Stars: ✭ 266 (-4.32%)
Mutual labels:  tutorial
React Ssd1306
πŸ“Ÿ A React Renderer for SSD1306 OLED chip on Raspberry Pi.
Stars: ✭ 273 (-1.8%)
Mutual labels:  tutorial
Crystal Book
Crystal docs at https://crystal-lang.org/reference
Stars: ✭ 275 (-1.08%)
Mutual labels:  tutorial
Line Bot Tutorial
line-bot-tutorial use python flask
Stars: ✭ 267 (-3.96%)
Mutual labels:  tutorial
Buildapks
Really quickly build APKs on handheld device (smartphone and tablet) in Amazon, Android, Chromebook, PRoot and WindowsπŸ“² See https://buildapks.github.io/docsBuildAPKs/setup to start building APKs.
Stars: ✭ 272 (-2.16%)
Mutual labels:  tutorial
Pytorch Image Classification
Tutorials on how to implement a few key architectures for image classification using PyTorch and TorchVision.
Stars: ✭ 272 (-2.16%)
Mutual labels:  tutorial
Neurokit
NeuroKit2: The Python Toolbox for Neurophysiological Signal Processing
Stars: ✭ 264 (-5.04%)
Mutual labels:  tutorial
Generative models tutorial with demo
Generative Models Tutorial with Demo: Bayesian Classifier Sampling, Variational Auto Encoder (VAE), Generative Adversial Networks (GANs), Popular GANs Architectures, Auto-Regressive Models, Important Generative Model Papers, Courses, etc..
Stars: ✭ 276 (-0.72%)
Mutual labels:  tutorial
Rcore Tutorial
Tutorial for rCore OS step by step (3rd edition)
Stars: ✭ 272 (-2.16%)
Mutual labels:  tutorial
Front End Web Development Resources
This repository contains content which will be helpful in your journey as a front-end Web Developer
Stars: ✭ 3,452 (+1141.73%)
Mutual labels:  tutorial
Project Minimek
A sample app to demonstrate various useful Redux techniques, accompanying the blog series at http://blog.isquaredsoftware.com/series/practical-redux
Stars: ✭ 266 (-4.32%)
Mutual labels:  tutorial
Guide.elm Lang.org
My book introducing you to Elm!
Stars: ✭ 270 (-2.88%)
Mutual labels:  tutorial
Vue Demo Collection
A collection of Vue.js demos
Stars: ✭ 274 (-1.44%)
Mutual labels:  tutorial
Deep Learning Keras Tensorflow
Introduction to Deep Neural Networks with Keras and Tensorflow
Stars: ✭ 2,868 (+931.65%)
Mutual labels:  tutorial
Poisson blend
Seamless copy-and-paste of images with Poisson Blending.
Stars: ✭ 277 (-0.36%)
Mutual labels:  tutorial
Plotlydash Flask Tutorial
πŸ“ŠπŸ“‰Embed Plotly Dash into your Flask applications.
Stars: ✭ 265 (-4.68%)
Mutual labels:  tutorial
Zerotoblockchain
Tutorial for Zero to Blockchain series
Stars: ✭ 272 (-2.16%)
Mutual labels:  tutorial
Cryptocurrency Analysis Python
Open-Source Tutorial For Analyzing and Visualizing Cryptocurrency Data
Stars: ✭ 278 (+0%)
Mutual labels:  tutorial
Golang Tutorials
Go Tutorials - Let's get our hands really dirty by writing a lot of Golang code
Stars: ✭ 277 (-0.36%)
Mutual labels:  tutorial
Generative Adversarial Networks
Tutorial on GANs
Stars: ✭ 275 (-1.08%)
Mutual labels:  tutorial

Lerna tutorial

TLDR;

  • npm install (installs lerna)

  • lerna bootstrap (connects all the packages)

  • npm -C ./packages/usage run start (console logs "alpha" and "beta" from combind use example module)

  • Tree Structure

  • packages

    • alpha (deps: [])
    • beta (deps: [])
    • usage (deps: ["alpha", "beta"])

Summary

First off, What is lerna? lerna is a tool that allows you to maintain multiple npm packages within one repository.

There's a couple of benefits to this kind of approach, the paradigm is called a monorepo, and more can be read about it from the source of babel, and react.

Here's the gist:

  • Single lint, build, test and release process.
  • Easy to coordinate changes across modules.
  • Single place to report issues.
  • Easier to setup a development environment.
  • Tests across modules are ran together which finds bugs that touch multiple modules easier.

Getting started.

For this demo I'm going to be using [email protected]. lerna is a CLI (command line interface) tool. You're going to want to install it with the --global (-g) flag.

npm i [email protected] -g

Then once it's done installing your going to want to run the following

mkdir my-monorepo && cd $_ && lerna init

This will do a couple of things.

  • Creating packages folder.
  • Updating package.json.
  • Creating lerna.json.

The /packages folder is where all of your packages belong. Let's go about making a new package alpha.

cd packages
mkdir alpha
cd alpha
npm init -y
echo "module.exports = 'alpha'" > index.js

Lets go through the same steps for another package beta.

First go up one directory:

cd ..

Now go about creating beta.

mkdir beta
cd beta
npm init -y
echo "module.exports = 'beta'" > index.js

Now we're going to create a usage package that uses both alpha and beta as dependencies.

First go up one directory:

cd ..

Now go about creating \usage.

mkdir usage
cd usage
npm init -y
touch index.js

Open up /packages/usage/index.js in a text editor and paste this in.

var alpha = require('alpha')
var beta = require('beta')
console.log(alpha + " " + beta)

We're almost there. At this point your whole project should look something like this:

.
β”œβ”€β”€ README.md
β”œβ”€β”€ lerna.json
β”œβ”€β”€ package.json
└── packages
    β”œβ”€β”€ alpha
    β”‚   β”œβ”€β”€ index.js
    β”‚   └── package.json
    β”œβ”€β”€ beta
    β”‚   β”œβ”€β”€ index.js
    β”‚   └── package.json
    └── usage
        β”œβ”€β”€ index.js
        └── package.json

What you want to do now is go into /packages/usage/package.json and add these lines under dependencies.

{
  "dependencies": {
    "alpha": "1.0.0",
    "beta": "1.0.0"  
  }
}

Now you need to wire everything up with this command.

lerna bootstrap

The output from this command should look something like this:

Lerna v2.0.0-beta.20
Linking all dependencies
Successfully bootstrapped 3 packages.

Now using the tree command once more (brew install tree) we can see the folder structure we can see what lerna did.

.
β”œβ”€β”€ README.md
β”œβ”€β”€ lerna.json
β”œβ”€β”€ package.json
└── packages
    β”œβ”€β”€ alpha
    β”‚   β”œβ”€β”€ index.js
    β”‚   β”œβ”€β”€ node_modules
    β”‚   └── package.json
    β”œβ”€β”€ beta
    β”‚   β”œβ”€β”€ index.js
    β”‚   β”œβ”€β”€ node_modules
    β”‚   └── package.json
    └── usage
        β”œβ”€β”€ index.js
        β”œβ”€β”€ node_modules
        β”‚   β”œβ”€β”€ alpha
        β”‚   β”‚   β”œβ”€β”€ index.js
        β”‚   β”‚   └── package.json
        β”‚   └── beta
        β”‚       β”œβ”€β”€ index.js
        β”‚       └── package.json
        └── package.json

It added two stubbed (my term not lerna's) modules. If you peak inside /packages/usage/node_modules/alpha/index.js you can see what I mean.

contents of ./packages/usage/node_modules/alpha/index.js

module.exports = require("/Users/thomas/Desktop/lerna-tutorial/packages/alpha");

Note: This is an absolute path to the module. So if you ever move your lerna project you'll need to rerun lerna bootstrap.

And voila! When we run node ./packages/usage/index.js we get our expected output!

alpha beta
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].