0

I am following the instruction to use Numeral.js.

I insert <script src="numeral.min.js"></script> before the end of my <body>.

when I reload the page i get the following error:

GET file:///<project_path>/numeral.min.js net::ERR_FILE_NOT_FOUND

And if I use numeral(1000).format('0,0') I get ReferenceError: numeral is not defined

same problem if I use <script src="//cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>:

GET file://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js net::ERR_INVALID_URL

What am I doing wrong? how do you use numeral.js?

user3755529
  • 1,050
  • 1
  • 10
  • 30

1 Answers1

1

Try to either :

  • specify https:// instead of // at the beginning of the cdn url
  • copy numeral.min.js next to your html file on disk

// means "use the same scheme as current page"

If you opened your html file by opening the file from your disk in your browser, it's url will be a file:// url, hence the error when you tried accessing the file with //<cdn>/...

An alternate way is to start a webserver on your machine and access your page through http(s)://localhost:someport/my test.html

LeGEC
  • 46,477
  • 5
  • 57
  • 104