在Angular 7中安装devDependencies或Dependencies

时间:2019-04-29 09:49:07

标签: angular package.json

我对应该在哪里真正安装ngxs,bootstrap,chart.js,ng-bootstrap,ng-select,sweetalert等软件包感到困惑?我遇到了几个问题,但是我仍然对应该将这些软件包放在哪里感到困惑? 谁能告诉下面的代码是否正确?谢谢

"dependencies": {
    "@angular/animations": "^7.2.11",
    "@angular/common": "^7.2.11",
    "@angular/compiler": "^7.2.11",
    "@angular/core": "^7.2.11",
    "@angular/forms": "^7.2.11",
    "@angular/http": "^7.2.11",
    "@angular/platform-browser": "^7.2.11",
    "@angular/platform-browser-dynamic": "^7.2.11",
    "@angular/platform-server": "^7.2.11",
    "@angular/pwa": "^0.10.7",
    "@angular/router": "^7.2.11",
    "@angular/service-worker": "^7.2.11",
    "@ngxs/router-plugin": "^3.4.3",
    "@ngxs/storage-plugin": "^3.4.3",
    "@ngxs/store": "^3.4.3",
    "bootstrap": "4.0.0",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.6.5",
    "intl": "^1.2.5",
    "ngx-perfect-scrollbar": "5.3.5",
    "node-sass": "^4.11.0",
    "resize-observer-polyfill": "^1.5.1",
    "rxjs": "^6.4.0",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.10.7",
    "@angular/cli": "^7.1.0",
    "@angular/compiler-cli": "^7.1.0",
    "@angular/language-service": "^7.1.0",
    "@ng-bootstrap/ng-bootstrap": "^4.0.0",
    "@ng-select/ng-select": "^2.12.0",
    "@ngxs/devtools-plugin": "^3.4.1",
    "@ngxs/logger-plugin": "^3.4.1",
    "@types/jasmine": "^2.8.12",
    "@types/node": "^9.6.37",
    "chart.js": "^2.8.0",
    "codelyzer": "^4.5.0",
    "jasmine-core": "^3.3.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^2.0.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.4.2",
    "karma-jasmine": "^1.1.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "ngx-pagination": "^3.2.1",
    "protractor": "^5.4.1",
    "rxjs-compat": "^6.3.3",
    "sweetalert2": "^7.29.2",
    "ts-node": "^5.0.1",
    "tslint": "^5.7.0",
    "typescript": "3.2.4"
  }

2 个答案:

答案 0 :(得分:1)

  

devDependencies 是仅在开发过程中需要的模块

     

依赖项是运行时也需要的模块。

     

rails db:migrateng-selectng-bootstrapngx-pagination是   运行时所需的软件包,即运行您的应用,并且应该是   您的项目。

     

sweetalert2将程序包另存为devDependency

     

npm install --save-dev将程序包另存为依赖项

也请注意

  

在部署应用程序时,需要将模块中的依赖项   已安装,否则您的应用将无法运行 devDependencies中的模块不   不需要安装在生产服务器上   在该计算机上进行开发

这应该是您的npm install --save

package.json

答案 1 :(得分:0)

我认为判断依赖项或devDependencies中应该包含的内容非常容易。在构建时打包到捆绑软件的所有内容都必须依赖于依赖项,而仅在构建时需要或有助于在本地构建解决方案的其他内容应归入devDependencies(gulp,grunt,打字稿,类型等)。

在上面的示例中,ng-select,ng-bootstrap,ngx-pagination和sweetalert2必须在内部依赖项中。