为模型和数据库模式添加express和Mongo

时间:2016-09-19 15:10:58

标签: node.js mongodb express mongoose

我正在开发一个Web应用程序并使用grunt来管理任务。 这是我正在使用的package.json文件。现在我需要为此应用程序包含express和mongodb架构。

使用npm install express和npm install mongoose,是否会自动安装所有依赖项,还是应该使用单独的命令?

帮我解决这个问题。谢谢。

{
  "name": "square",
  "version": "3.1.0",
  "devDependencies": {
    "connect-livereload": "~0.5.2",
    "grunt": "~0.4.5",
    "grunt-autoprefixer": "~3.0.0",
    "grunt-concurrent": "~2.1.0",
    "grunt-contrib-clean": "~0.7.0",
    "grunt-contrib-coffee": "~0.13.0",
    "grunt-contrib-compass": "~1.0.0",
    "grunt-contrib-concat": "~0.5.0",
    "grunt-contrib-connect": "^0.11.2",
    "grunt-contrib-copy": "~0.8.0",
    "grunt-contrib-cssmin": "~0.14.0",
    "grunt-contrib-htmlmin": "~0.6.0",
    "grunt-contrib-jade": "~0.15.0",
    "grunt-contrib-jshint": "~0.11.0",
    "grunt-contrib-less": "~1.1.0",
    "grunt-contrib-uglify": "~0.11.0",
    "grunt-contrib-watch": "~0.6.1",
    "grunt-injector": "^0.6.1",
    "grunt-open": "~0.2.3",
    "grunt-usemin": "~3.1.0",
    "jshint-stylish": "^2.1.0",
    "load-grunt-tasks": "~3.4.0",
    "time-grunt": "~1.3.0",
    "serve-static": "^1.10.0",
    "http-errors": "^1.3.1",
    "debug": "^2.2.0",
    "depd": "^1.1.0",
    "destroy": "^1.0.3",
    "range-parser": "^1.0.3",
    "mime": "^1.3.4",
    "fresh": "^0.3.0",
    "etag": "^1.7.0",
    "ms": "^0.7.1",
    "on-finished": "^2.3.0",
    "statuses": "^1.2.1"    
  },
  "engines": {
    "node": ">=0.10.0"
  }
}

2 个答案:

答案 0 :(得分:0)

您可以使用

npm install express --save-dev 
npm install mongoose --save-dev 

这将保存到package.json文件中的devDepencies列表中。当您安装每个依赖项时,将自动安装任何表达或需要的依赖项。

答案 1 :(得分:0)

使用以下命令:

npm install express --save
npm install mongoose --save

这将安装所有依赖项到package.json,如果你想在其他系统上安装它们,你可以使用

npm install

这将安装package.json中提到的所有依赖项。