0

I installed messageformat from npm for use in my angular-boostrap project in conjunction with angular-translate.

If I simply add messageformat v0.3.1 via CDN, everything works as expected. But I would like to use messageformat installed from npm. The trouble is, I have no idea how. None of the scripts in the messageformat npm package looks anything like the one on CDN. I am wondering if I need to build it or something? But then again, the documentation on npm for messageformat does not mention anything apart from "npm install...".

What am I missing?

[Edit]
There is both a bin and a lib folder in the project. Both contain messageformat.js, but none of them are working, and they look nothing like the one from CDN. If I include node_modules/messageformat/lib/messageformat.js I get a "module is not defined" error. If I include node_modules/messageformat/bin/messageformat.js I get "invalid or unexpected token" ... Therefore I suspect there is a step missing to get a script like the one from CDN

Jette
  • 2,459
  • 28
  • 37

2 Answers2

0

you need to add the files instead of cdn :

<script src="path/to/node_module/messageformat/messageformat.js"></script>

Dan M. CISSOKHO
  • 1,070
  • 1
  • 12
  • 27
  • There is both a bin and a lib folder in the project. Both contain messageformat.js, but none of them are working, and they look nothing like the one from CDN. If I include node_modules/messageformat/lib/messageformat.js I get a "module is not defined" error. If I include node_modules/messageformat/bin/messageformat.js I get "invalid or unexpected token" ... Therefore I suspect there is a step missing to get a script like the one from CDN. – Jette Aug 18 '16 at 12:31
0

It turns out that version 0.3.1 of the npm package did not include a UMD version of the script, but since then version 1.0.0 is out, and a script ready for use in browsers now ships with the npm package. https://github.com/messageformat/messageformat.js/issues/157

Jette
  • 2,459
  • 28
  • 37