If you ever want to publish your own library, you will need to upload a new project onto Github.

In this tutorial, I will teach all of you how to create your own react project, upload it to GitHub, create another react project, and uploading the initially created project as a package.

To begin, you need to install node on your machine with the following command:

  • curl “https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- https://nodejs.org/dist/latest/ | sed -nE ‘s|.>node-(.).pkg.*|\1|p’)}.pkg” > “$HOME/Downloads/node-latest.pkg” && sudo installer -store -pkg “$HOME/Downloads/node-latest.pkg” -target “/”

Now create a folder and create index.js. Index.js is where you will be exporting your functions from the package.

Afterward, create a package.json within the same folder and include the following:

This will be a repository consists of util functions that we will export.

Afterward, create index.js and include the following:

Next, we need to log in to github.com. If you haven’t created any account please do so.

Afterward, go to https://github.com/new and create a public repository. You can name it anything and you want and don’t initialize the readme. Click “Create Repository”.

Now go to terminal and ls to the directory/folder that contains index.js(I name it as utilsExport.js but it is really index.js) and package.json. Your project structure should look something similar to this:

Image for post

#react #front-end-development #npm #github #javascript

How to Build Your Own React Package and NPM Install in Another Project
2.70 GEEK