如何获取/创建有角度的package.json脚本?

时间:2018-10-03 15:26:58

标签: json angular package.json

我查看了angular.io网站,但在其他文档下找不到package.json文件。

这是如何创建的?我需要将其下载到什么地方吗?。

2 个答案:

答案 0 :(得分:1)

要在Vineela's answer上展开:

如果要使用Angular CLI创建和管理角度应用程序,必须首先在本地环境中配置Angular CLI:

npm install -g @angular/cli

只有在全局安装了Angular CLI之后,才能生成一个新项目,该项目将包含(生成的)package.json中该项目的所有脚本,类似于rhavelka在其answer中共享的脚本

ng new my-project

从Angular CLI生成的package.json:6.0.7(请注意默认脚本):

{
  "name": "sample",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "core-js": "^2.5.4",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.6",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.7",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
  }
}

答案 1 :(得分:0)

当您使用命令“ ng new projectname”创建新项目时,Angular将为您创建package.json文件。