<commit_before>---
layout: post
name: NPM-Link
title: How to use 'npm link'
date: 2016-02-11 10:00:00 +00:00
author: <NAME>
---

If you are working on a node project there may come a point where your app has a dependency on another custom module you have created.

For example, on my current project, my colleagues and I are responsible for a custom node module called the 'Search Component'. This can be inserted anywhere in the application (usually the header), allowing the user to search the site's content and instantly see a results summary.
 
![The Search Component](../images/search-component.png)
<small>*Above: The Search Component is a custom node module that can be inserted anywhere in the parent application*</small>
 
Although automated testing has it uses, sometimes manual testing still reigns supreme, particularly when it comes to testing certain interactions and observing user interface changes. 

This was particularly true for me when it came to manually testing changes to our Search Component.

The issue is that simply modifying your module dependency and firing up the app won't allow you to observe those changes.

Luckily, npm has a way to make this happen using the **npm link** command.

#### NPM Link in a nutshell

The [npm documentation](https://docs.npmjs.com/cli/link) defines **npm link** as a *'means to symlink a package folder'*
Put simply, its a means to connect your parent application to a module you have locally on you machine. When you run the application, any changes you make to the dependency will be reflected in the application.

#### How to NPM Link

1. In the terminal, navigate to the folder of the module you want to modify and run the command `npm link`. This makes the module globally available to the rest of your application.

2. Navigate to the folder of the application that depends on the module you want to modify. In the root run the command `npm link [name of module you want to modify]`<commit_msg>Correction to post publish date<commit_after>---
layout: post
name: NPM-Link
title: How to use 'npm link'
date: 2016-11-02 10:00:00 +00:00
author: <NAME>
---

If you are working on a node project there may come a point where your app has a dependency on another custom module you have created.

For example, on my current project, my colleagues and I are responsible for a custom node module called the 'Search Component'. This can be inserted anywhere in the application (usually the header), allowing the user to search the site's content and instantly see a results summary.
 
![The Search Component](../images/search-component.png)
<small>*Above: The Search Component is a custom node module that can be inserted anywhere in the parent application*</small>
 
Although automated testing has it uses, sometimes manual testing still reigns supreme, particularly when it comes to testing certain interactions and observing user interface changes. 

This was particularly true for me when it came to manually testing changes to our Search Component.

The issue is that simply modifying your module dependency and firing up the app won't allow you to observe those changes.

Luckily, npm has a way to make this happen using the **npm link** command.

#### NPM Link in a nutshell

The [npm documentation](https://docs.npmjs.com/cli/link) defines **npm link** as a *'means to symlink a package folder'*
Put simply, its a means to connect your parent application to a module you have locally on you machine. When you run the application, any changes you make to the dependency will be reflected in the application.

#### How to NPM Link

1. In the terminal, navigate to the folder of the module you want to modify and run the command `npm link`. This makes the module globally available to the rest of your application.

2. Navigate to the folder of the application that depends on the module you want to modify. In the root run the command `npm link [name of module you want to modify]`
{'fraction_non_alphanumeric': 0.055752660922453116, 'fraction_numerical': 0.01013684744044602, 'mean_word_length': 4.370068027210884, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3600852', 'n_tokens_mistral': 992, 'n_tokens_neox': 927, 'n_words': 627}