javascript - Using the shell provided with NodeJS -
once you've installed nodejs, you'll have executable in computer named nodejs shell. wondering can that... here you're able run js code as, example, in browser's console, great.
now, possible require modules in env? doing so, i'd able run js code using functions provided modules imo really, great.
i've tried installing modules -g option (for example npm install -g express); (in shell) want run require('express') doesen't work, says:
error: cannot find module 'express' @ function.module._resolvefilename ...
ideas?
as per issue #5431, looks node.js repl doesn't find globally-installed modules , expected behaviour.
in article linked issue, reads:
- if you’re installing want use in program, using require('whatever'), install locally, @ root of project.
this case, sou need install express locally:
$ npm install express $ node > var express = require('express'); undefined note undefined result because of var statement, did work.
Comments
Post a Comment