How to install JSON.pm perl module on OSX

ragulka picture ragulka · Aug 19, 2012 · Viewed 42.5k times · Source

I am trying to use the po2json parser/converter from the JS gettext library (http://jsgettext.berlios.de/), but when I try to convert I get this error:

Can't locate JSON.pm in @INC (@INC contains: /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at ./po2json line 23.
BEGIN failed--compilation aborted at ./po2json line 23.

As far as I understand I am missing a perl module, namely JSON.pm, an I think it's this one: http://cpansearch.perl.org/src/MAKAMAKA/JSON-2.53/lib/JSON.pm

Now, how do I install it on OSX? I am using Mountain Lion.

I tried to do cpan install JSON, but it doesn't work, I get the following error:

Writing Makefile for JSON
  MAKAMAKA/JSON-2.53.tar.gz
  make -- NOT OK
'YAML' not installed, will not store persistent state
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible

Answer

Gavin picture Gavin · May 5, 2013

Use homebrew to install cpanm:

brew install cpanm

Then you can install JSON with

sudo cpanm install JSON