npm API – cannot require module npm

npm API – cannot require module npm


On the npm docs it says that I can require it and use it’s api however when I do:

$ node
var npm = require("npm");
Error: Cannot find module 'npm'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at repl:1:11
    at REPLServer.self.eval (repl.js:109:21)
    at rli.on.self.bufferedCmd (repl.js:258:20)
    at REPLServer.self.eval (repl.js:116:5)
    at Interface.<anonymous> (repl.js:248:12)
    at Interface.EventEmitter.emit (events.js:96:17)
Problem courtesy of: Ari Porad


it worked to do $ sudo npm install --save npm


Solution courtesy of: Ari Porad


Leave a Reply

Your email address will not be published. Required fields are marked *