How to install local npm package in a project

Article autor
April 20, 2020
How to install local npm package in a project
Elixir Newsletter
Join Elixir newsletter

Subscribe to receive Elixir news to your inbox every two weeks.

Oops! Something went wrong while submitting the form.
Elixir Newsletter
Expand your skills

Download free e-books, watch expert tech talks, and explore open-source projects. Everything you need to grow as a developer - completely free.

Table of contents

In some cases, like for testing purposes, you might want to use an npm package stored on a local machine. Here is how you can do that with one simple command.

In typical case scenario you pass a published package name when installing it via npm:

npm install jquery

Let's say you have awesome-editor library written by yourself stored on your local machine under ~/projects/awesome-editor.

Installing it in your project is as simple as:

npm install ~/projects/awesome-editor

Once the installation is finished you will see a new entry in package.json:

"awesome-editor": "file:<relative path goes here>",

That's it, you can now use it in your project!

Work with a team that keeps learning and building better software every day.

Related posts

Dive deeper into this topic with these related posts

No items found.

You might also like

Discover more content from this category

Manually update Apollo cache after GraphQL mutation

Ensuring that GraphQL mutations properly update your Apollo client's cache can be a bit tricky - here's how to manually control that.

Style spacing between repeated elements in CSS using flex gap

It's a pretty common scenario - you have to place a few elements in equal distances. E.g. unordered list items.

Load CSS as string using JS & Webpack import prefixes

People will tell you it's an antipattern, but what if a library needs you to do this?