← Back to Blog

NPM Basics June 2017: Creating an NPM Project

packageManager
github

By Kevin Hou

1 minute read

Create an NPM Environment

First, you need to create an NPM environment for your library so that NPM knows what dependencies and scripts are associated with the library. Run:

1npm init 2

Follow the instructions and it'll attempt to create a proper package.json for your project.

Installing Dependencies

1npm install --save react-redux 2
1npm install --save-dev babel-core 2

Global installation

1npm install -g eslint 2

Useful Dev Tools

Linter: Check for coding errors — saves a trip to the browser (Airbnb's linter is useful) Webpack: For building and compiling JSX, ES6, etc. It will create static site with the option to serve it up locally on the localhost.

Use GitHub Repo as the Public NPM Package

1npm i git://github.com/user/project.git#commit-ish --save 2

File structure of GitHub repo if you want to use it as a public package:

1library-name/ 2 demo/ 3 dist/ 4 src/ 5