1

I wanted to install a command line tool to convert yaml files into json files. Actually My real intention is to validate yaml files all at once in a directory.

I did some research and followed the instructions listed here and here. However, command line always tells me that -bash: yaml2json: command not found. I'm wondering if it's because the files weren't in my path? my $PATH looks like this:

/Users/luca/.rbenv/shims:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin:~/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

What should I do to get this work? Thank you very much!

Jordan Running
  • 102,619
  • 17
  • 182
  • 182
Penny
  • 1,218
  • 1
  • 13
  • 32
  • Did you use the `-g` option with `npm install`? It looks like your `$PATH` is correct. Does `/usr/local/bin/yaml2json` exist (it should be a symlink)? I suggest taking a look at this related answer: http://stackoverflow.com/questions/14803978/npm-global-path-prefix/14840304#14840304 – Jordan Running Dec 08 '15 at 18:20
  • Thank you! I used `-g` to install yaml2json, but the command line always throws me errors looking like this `npm ERR! tar.unpack untar error /Users/venga-penny/.npm/yaml2json/1.0.2/package.tgz` `npm ERR! Darwin 14.3.0` `npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "yaml2json"` ... So I'm not sure what is going wrong... – Penny Dec 08 '15 at 18:24

2 Answers2

3
  • if you are using Ubuntu use the below command to install the required package:

    • sudo apt install libghc-yaml-dev
  • if you are using RHEL/CentOS use the below command to get the name of the package:

    • yum provides *bin/yaml2json
    • then install the package using sudo yum install <package-name>
0

It seems like sudo npm install-g yaml2json can solve the problem...But this yaml2json module can only work with one file at a time instead of files in a directory...

Plus when I run yaml2json ./_index.yaml, it returns "project_path" Not sure what it means and can't find the converted .json file either...

Penny
  • 1,218
  • 1
  • 13
  • 32