node.js - request nodejs package not being found -
i install request package using npm. appears located here: /usr/local/lib/node_modules/request/
var request = require("request"); request("http://www.google.com", function(error, response, body) { console.log(body); });
module.js:340 throw err; ^ error: cannot find module 'request'...
what need alter or perform? further info, mac osx, node-v0.10.26.pkg, sudo -h npm install -g request, no errors
i think have installed package using -g
flag (global).
that's not how should install package.
to fix problem, install package locally:
npm install request
or use package.json
file persist dependency:
{ "name": "test", "version: "0.1.0", "dependencies": [ "request": "*" ] }
Comments
Post a Comment