-3

i need to run npm in ruby console to run grunt with compass, but when i typing npm in ruby console says "npm is not a command" but when i typing in node console works good. some help? thanks!

1 Answers1

1

[I] need to run npm in ruby console

The #system method, "Executes command… in a subshell.", see: http://ruby-doc.org/core-2.2.0/Kernel.html#method-i-system

$ irb
irb(main):001:0> system('npm')

Usage: npm <command>

where <command> is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get,
    help, help-search, i, init, install, install-test, it, link,
    list, ln, logout, ls, outdated, owner, pack, ping, prefix,
    prune, publish, rb, rebuild, repo, restart, root, run,
    run-script, s, se, search, set, shrinkwrap, star, stars,
    start, stop, t, tag, team, test, tst, un, uninstall,
    unpublish, unstar, up, update, v, version, view, whoami

npm <cmd> -h     quick help on <cmd>
npm -l           display full usage info
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    /Users/dev/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@3.8.9 /usr/local/lib/node_modules/npm
=> false
irb(main):002:0> 

Alternatively, backticks (`cmd`) return "the standard output of running cmd in a subshell.", see: http://ruby-doc.org/core-2.2.0/Kernel.html#method-i-60

$ irb
irb(main):001:0> puts `npm`

Usage: npm <command>

where <command> is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get,
    help, help-search, i, init, install, install-test, it, link,
    list, ln, logout, ls, outdated, owner, pack, ping, prefix,
    prune, publish, rb, rebuild, repo, restart, root, run,
    run-script, s, se, search, set, shrinkwrap, star, stars,
    start, stop, t, tag, team, test, tst, un, uninstall,
    unpublish, unstar, up, update, v, version, view, whoami

npm <cmd> -h     quick help on <cmd>
npm -l           display full usage info
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    /Users/dev/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@3.8.9 /usr/local/lib/node_modules/npm
=> nil
irb(main):002:0> 
SoAwesomeMan
  • 3,226
  • 1
  • 22
  • 25