node.js cannot find module 'mongodb'

前端 未结 11 2056
天涯浪人
天涯浪人 2020-12-07 22:36

I am going through my first node.js project. I\'ve installed mongodb, have a server.js file, and when I try to run it I get this error

module.js:340
    thro         


        
11条回答
  •  囚心锁ツ
    2020-12-07 22:46

    Error

    jamsheed-h110m-s2ph:~/project/jamsheed/meanStack/mean$ node server.js
    module.js:538
        throw err;
        ^
    Error: Cannot find module 'mongodb'
        at Function.Module._resolveFilename (module.js:536:15)
        at Function.Module._load (module.js:466:25)
        at Module.require (module.js:579:17)
        at require (internal/module.js:11:18)
        at Object. (/home/haseeb/project/jamsheed/meanStack/mean/server.js:3:13)
        at Module._compile (module.js:635:30)
        at Object.Module._extensions..js (module.js:646:10)
        at Module.load (module.js:554:32)
        at tryModuleLoad (module.js:497:12)
        at Function.Module._load (module.js:489:3)
    

    Solved

    npm install mongodb

    Edit package.json = "mongodb": "^3.0.1", change "mongodb": "3.0.1",

提交回复
热议问题