node.js cannot find module 'mongodb'

前端 未结 11 2094
天涯浪人
天涯浪人 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:50

    My problem was that when I originally created my package.json file, I had made the "version" key correspond to a value of "1.0.0". When I changed that to version value to reflect the version I wanted to use under my "dependencies" key, I got rid of the error. There is a picture below of the potential fix. Notice how the "version" and "mongodb" under "dependencies" match.

提交回复
热议问题