node.js - How To Require Node Module In Node REPL Without Installing Globally? -
as per node js instruction manual, highly discouraged install node module globally.
i tried variety of things. executed following commands in home directory, in git file (with node_modules) folder, , actual node_modules folder.
> var express=require('express'); undefined > var express=require('node_modules/express'); error: cannot find module 'node_modules/express' @ function.module._resolvefilename (module.js:338:15) @ function.module._load (module.js:280:25) @ module.require (module.js:364:17) @ require (module.js:380:17) @ repl:1:13 @ replserver.self.eval (repl.js:110:21) @ repl.js:249:20 @ replserver.self.eval (repl.js:122:7) @ interface.<anonymous> (repl.js:239:12) @ interface.eventemitter.emit (events.js:95:17)
note in above, expected them in git folder (with node_modules). found curious line
> var express=require('express');
yielded
undefined
in home directory, same "cannot find module" error.
your require
statement working fine. ignore undefined
, that's node repl. undefined
explained here, , see comments below links additional material that.
you can verify with:
mkdir /tmp/test-repl cd /tmp/test-repl npm install express node > var express = require('express'); undefined > express //long object express module gets printed
Comments
Post a Comment