npm安装后找不到模块

时间:2021-08-20 20:10:54

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

我正在通过Microsoft Azure在Ubuntu服务器上运行Node.js.我有一个看起来像这样的package.json:

{
  "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.

现在,当我运行sudo npm install时,它会尝试安装模块。但是,如果我然后尝试使用节点server.js运行我的应用程序,我发现我的模块的某些依赖项没有安装。

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?

我需要通过一个很长的列表并手动安装许多模块。为什么会发生这种情况?如何才能从package.json中正确安装所有内容?

2 个解决方案

#1


1  

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.

所以事实证明这与MongoDB的版本有关。我刚刚将版本更改为1.3.19,一切都很开心。

#2


0  

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

你在Azure上运行npm install吗?试试npm install --production

#1


1  

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.

所以事实证明这与MongoDB的版本有关。我刚刚将版本更改为1.3.19,一切都很开心。

#2


0  

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

你在Azure上运行npm install吗?试试npm install --production