Quick and dirty tricks to get raml2html on your Ubuntu machine 🙂
First we need to install nodejs and npm from official repo.
1 2 |
sudo apt-get install nodejs sudo apt-get install npm |
Then we install raml2html from npm library:
sudo npm i -g raml2html
If the installation is successful you’ll see an output like:
1 2 3 4 5 6 7 8 9 |
/usr/local/bin/raml2html -> /usr/local/lib/node_modules/raml2html/bin/raml2html raml2html@3.0.1 /usr/local/lib/node_modules/raml2html ├── nunjucks-markdown@2.0.0 ├── marked@0.3.6 ├── commander@2.9.0 (graceful-readlink@1.0.1) ├── raml-jsonschema-expander@1.1.2 (urllib-sync@1.1.3) ├── nunjucks@2.4.3 (asap@2.0.4, yargs@3.32.0, chokidar@1.6.0) ├── minimize@2.0.0 (emits@3.0.0, argh@0.1.4, node-uuid@1.4.7, htmlparser2@3.9.1, diagnostics@1.0.1, cli-color@1.1.0, async@2.0.1) └── raml2obj@3.0.0 (raml-parser@0.8.18) |
Last verification:
raml2html --help
1 2 |
raml2html --help /usr/bin/env: node: No such file or directory |
Oops, looks like something’s wrong with NPM
Try to create symlink and re-run raml2html
sudo ln -s /usr/bin/nodejs /usr/bin/node
If you hit this issue:
1 2 3 4 5 6 7 8 9 10 11 |
/usr/local/lib/node_modules/raml2html/bin/raml2html:5 const program = require('commander'); ^^^^^ SyntaxError: Use of const in strict mode. at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:902:3 |
Try to cleanup npm cache and upgrade to the latest version:
1 2 3 |
sudo npm cache clean -f sudo npm install -g n sudo n stable |
Voila!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[arushkov@dev]$ sudo n stable install : node-v6.6.0 mkdir : /usr/local/n/versions/node/6.6.0 fetch : https://nodejs.org/dist/v6.6.0/node-v6.6.0-linux-x64.tar.gz ######################################################################## 100.0% installed : v6.6.0 [arushkov@dev]$ raml2html --help Usage: raml2html [options] [RAML input file] Options: -h, --help output usage information -V, --version output the version number -i, --input [input] RAML input file -t, --template [template] Filename of the custom Nunjucks template -o, --output [output] HTML output file |
And finally some action:
raml2html -o index.html index.raml
For more refer to the official raml2html repo on github: https://github.com/raml2html/raml2html
Install raml2html on Ubuntu 14.04