5

How to Use Lerna to Create a Monorepo for Multiple Node Packages

 2 years ago
source link: https://hackernoon.com/how-to-use-lerna-to-create-a-monorepo-for-multiple-node-packages-u31i34nl
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to Use Lerna to Create a Monorepo for Multiple Node Packages

Create two packages, hello-world, and aloha-world (with the default options):

0 reactions
lerna create hello-world
lerna create aloha-world
lerna create
 is Lerna’s way to help us create packages managed by a Lerna initialized repo.
0 reactions

Inside both of the packages, modify the corresponding js files to have them greet as we want them to:

0 reactions

aloha-world.js

0 reactions
'use strict';

module.exports = alohaWorld;

function alohaWorld() {
 console.log('Aloha World');
}

hello-world.js

0 reactions
'use strict';

module.exports = helloWorld;

function helloWorld() {
 console.log('Hello World');
}

Now we have to make a modification in our package.json to contain the GitHub username of our account / organization:

0 reactions
{
 "name": "@aspectom/aloha-world",
 "version": "0.0.0",
 "description": "> TODO: description",
 "author": "Tom Z <[email protected]>",
 "homepage": "",
 "license": "ISC",
 "main": "lib/aloha-world.js",
 "directories": {
   "lib": "lib",
   "test": "__tests__"
 },
 "files": [
   "lib"
 ],
 "repository": {
   "type": "git",
   "url": "[email protected]:aspectom/learna.git"
 },
 "scripts": {
   "test": "echo \"Error: run tests from root\" && exit 1"
 }
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK