Installation

Numeral.js can be easily integrated into your project using various methods, including package managers like npm or by including it directly in the browser via a CDN.

Using npm

For Node.js projects or front-end projects using a build system, the recommended way to install Numeral.js is through npm.

npm install numeral

Once installed, you can require it in your project:

const numeral = require('numeral');

const number = numeral(1000);
const formattedNumber = number.format('0,0');
console.log(formattedNumber); // '1,000'

Browser / CDN

To use Numeral.js directly in a browser, you can include it from a CDN like CDNJS. Add the following script tag to your HTML file:

<script src="//cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>

This will make the numeral function available globally in your application.

<script>
  var myNumber = numeral(1234.56);
  var myString = myNumber.format('$0,0.00'); // '$1,234.56'
  document.body.innerText = myString;
</script>

Bower

For projects still using Bower, you can install Numeral.js with the following command:

bower install numeral