ng build不识别dev和prod以外的任何环境

时间:2018-03-26 16:41:20

标签: angular

当我尝试运行以下命令时,有人可以告诉我为什么会出现以下错误吗?也许我这样做不正确?我有预测试和测试,我想与dev或prod建立不同。

非常感谢任何帮助。

ng build --enivronment=pretest --target=pretest -bh http://somehost.stuff.gov:7019

我收到以下错误:

    The option '--enivronment' is not registered with the build command. Run `ng build --help` for a list of supported options.
Invalid build target. Only 'development' and 'production' are available.
Error: Invalid build target. Only 'development' and 'production' are available.
    at NgCliWebpackConfig.validateBuildOptions (C:\Users\Denis.Putnam\Documents\development\pcocar-app\node_modules\@angular\cli\models\webpack-config
.js:55:19)
    at new NgCliWebpackConfig (C:\Users\Denis.Putnam\Documents\development\pcocar-app\node_modules\@angular\cli\models\webpack-config.js:12:14)
    at Class.run (C:\Users\Denis.Putnam\Documents\development\pcocar-app\node_modules\@angular\cli\tasks\build.js:30:31)
    at Class.run (C:\Users\Denis.Putnam\Documents\development\pcocar-app\node_modules\@angular\cli\commands\build.js:216:26)
    at resolve (C:\Users\Denis.Putnam\Documents\development\pcocar-app\node_modules\@angular\cli\ember-cli\lib\models\command.js:261:20)
    at new Promise (<anonymous>)
    at Class.validateAndRun (C:\Users\Denis.Putnam\Documents\development\pcocar-app\node_modules\@angular\cli\ember-cli\lib\models\command.js:240:12)
    at Promise.resolve.then.then (C:\Users\Denis.Putnam\Documents\development\pcocar-app\node_modules\@angular\cli\ember-cli\lib\cli\cli.js:140:24)
    at <anonymous>

这是我的.angular-cli.json文件:

    {
  "project": {
    "version": "1.0.0-beta.28.3",
    "name": "pcocar-app"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "pretest": "environments/environment.pretest.ts",
        "test": "environments/environment.test.ts",
        "preprod": "environments/environment.preprod.ts",        
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "files": "src/**/*.ts",
      "project": "src/tsconfig.json"
    },
    {
      "files": "e2e/**/*.ts",
      "project": "e2e/tsconfig.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false,
    "inline": {
      "style": false,
      "template": false
    },
    "spec": {
      "class": false,
      "component": true,
      "directive": true,
      "module": false,
      "pipe": true,
      "service": true
    }
  }
}

1 个答案:

答案 0 :(得分:1)

这是环境错字吗? ng build --enivronment=pretest --target=pretest -bh http://somehost.stuff.gov:7019

Angular并不总是支持多个构建环境,因此我还会检查您正在运行的版本。