简体   繁体   中英

cannot find module after npm install

I'm running Node.js on an Ubuntu server through Microsoft Azure. I have a package.json that looks like this:

{
  "author"       : "Coop",
  "name"         : "app-framework",
  "main"         : "server.js",
  "version"      : "0.0.0",
  "private"      : true,
  "dependencies" : {
    "express"            : "~4.7.2",
    "morgan"             : "~1.5.0",
    "bcrypt"             : "~0.8.0",
    "forever"            : "~0.13.0",
    "mongodb"            : "~1.4.25",
    "mongoose"           : "~3.6.2",
    "nodemailer"         : "~1.3.0",
    "body-parser"        : "~1.9.2",
    "method-override"    : "~2.3.0",
    "express-session"    : "~1.9.3",
    "connect-mongostore" : "~0.1.4",
    "nodemailer-sendgrid-transport" : "~0.1.0"
  }
}

Now when I run sudo npm install , it tries to install the modules. However, if I then try and run my application with node server.js , I discover that some dependencies of my modules did not install.

I'm having to go through a long list and manually install lots of modules. Why is this happening and how can I just get everything to install correctly from the package.json ?

So it turns out this was to do with the version of MongoDB. I just changed the version to 1.3.19 and everything was happy.

Are you running npm install on Azure? Try npm install --production

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM