angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng build -prod throws Data path "" should NOT have additional properties (p)

Open etsuo opened this issue 8 years ago • 29 comments

Workaround

@bvdmitri discovered (see below) that you can successfully build by using unabbreviated arguments:

ng build --target=production --environment=prod

Instead of:

ng build -prod

Versions

Angular CLI: 6.0.0-beta.6
Node: 8.9.0
OS: darwin x64
Angular: 6.0.0-beta.8
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

@angular/cdk: 6.0.0-beta.4
@angular/cli: 6.0.0-beta.6
@angular/material: 6.0.0-beta.4
@angular-devkit/architect: 0.0.7
@angular-devkit/build-optimizer: 0.4.6
@angular-devkit/build-webpack: 0.0.7
@angular-devkit/core: 0.4.6
@angular-devkit/schematics: 0.4.6
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 6.0.0-beta.6
@schematics/angular: 0.4.6
@schematics/package-update: 0.4.6
typescript: 2.7.2
webpack: 4.1.1

Repro steps

  1. ng build -prod
  2. error

Note: ng build without -prod builds fine.

Observed behavior

Schema validation failed with the following errors:
  Data path "" should NOT have additional properties (p).
Error: Schema validation failed with the following errors:
  Data path "" should NOT have additional properties (p).
    at MergeMapSubscriber.registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (/Users/dev/sakuraapi/sakuraapi.com/node_modules/@angular-devkit/architect/src/architect.js:218:39)
    at MergeMapSubscriber._tryNext (/Users/dev/sakuraapi/sakuraapi.com/node_modules/rxjs/operators/mergeMap.js:122:27)
    at MergeMapSubscriber._next (/Users/dev/sakuraapi/sakuraapi.com/node_modules/rxjs/operators/mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (/Users/dev/sakuraapi/sakuraapi.com/node_modules/rxjs/Subscriber.js:90:18)
    at MergeMapSubscriber.notifyNext (/Users/dev/sakuraapi/sakuraapi.com/node_modules/rxjs/operators/mergeMap.js:145:30)
    at InnerSubscriber._next (/Users/dev/sakuraapi/sakuraapi.com/node_modules/rxjs/InnerSubscriber.js:23:21)
    at InnerSubscriber.Subscriber.next (/Users/dev/sakuraapi/sakuraapi.com/node_modules/rxjs/Subscriber.js:90:18)
    at MapSubscriber._next (/Users/dev/sakuraapi/sakuraapi.com/node_modules/rxjs/operators/map.js:85:26)
    at MapSubscriber.Subscriber.next (/Users/dev/sakuraapi/sakuraapi.com/node_modules/rxjs/Subscriber.js:90:18)
    at SwitchMapSubscriber.notifyNext (/Users/dev/sakuraapi/sakuraapi.com/node_modules/rxjs/operators/switchMap.js:126:30)

Desired behavior

I'd like it to build my project without an error. :)

Mention any other details that might be useful (optional)

As mentioned above:

  1. I have a service worker configued
  2. I have an app shell configued
  3. I'm using beta to try to get around:
  • https://github.com/angular/angular/issues/20360
  • https://github.com/maciejtreder/angular-universal-pwa/blob/master/src/app/server-app.module.ts
  • https://github.com/angular/angular/pull/20782

.angular-cli.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "website"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "../node_modules/normalize.css/normalize.css",
        "sass/styles.scss"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      },
      "serviceWorker": true,
      "appShell": {
        "app": "sapi-app-shell",
        "route": "app-shell-path"
      }
    },
    {
      "root": "src",
      "outDir": "dist-server",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.server.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.server.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "../node_modules/normalize.css/normalize.css",
        "sass/styles.scss"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      },
      "serviceWorker": true,
      "platform": "server",
      "name": "sapi-app-shell"
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "src/tsconfig.spec.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "e2e/tsconfig.e2e.json",
      "exclude": "**/node_modules/**"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "scss",
    "component": {}
  }
}

etsuo avatar Mar 17 '18 22:03 etsuo

Same issue for me, it happens on npm start. The weird thing is that the issue appeared on one machine but not another. Here's the error:

Schema validation failed with the following errors:
  Data path "" should NOT have additional properties (i18nLocale).
Error: Schema validation failed with the following errors:
  Data path "" should NOT have additional properties (i18nLocale).
    at MergeMapSubscriber.registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (D:\Projects\Jaddeer\Jadir Client\node_modules\@angular-devkit\architect\src\architect.js:218:39)
    at MergeMapSubscriber._tryNext (D:\Projects\Jaddeer\Jadir Client\node_modules\rxjs\operators\mergeMap.js:122:27)
    at MergeMapSubscriber._next (D:\Projects\Jaddeer\Jadir Client\node_modules\rxjs\operators\mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (D:\Projects\Jaddeer\Jadir Client\node_modules\rxjs\Subscriber.js:90:18)
    at MergeMapSubscriber.notifyNext (D:\Projects\Jaddeer\Jadir Client\node_modules\rxjs\operators\mergeMap.js:145:30)
    at InnerSubscriber._next (D:\Projects\Jaddeer\Jadir Client\node_modules\rxjs\InnerSubscriber.js:23:21)
    at InnerSubscriber.Subscriber.next (D:\Projects\Jaddeer\Jadir Client\node_modules\rxjs\Subscriber.js:90:18)
    at MapSubscriber._next (D:\Projects\Jaddeer\Jadir Client\node_modules\rxjs\operators\map.js:85:26)
    at MapSubscriber.Subscriber.next (D:\Projects\Jaddeer\Jadir Client\node_modules\rxjs\Subscriber.js:90:18)
    at SwitchMapSubscriber.notifyNext (D:\Projects\Jaddeer\Jadir Client\node_modules\rxjs\operators\switchMap.js:126:30)

AlQuraian avatar Mar 18 '18 13:03 AlQuraian

It seems that the issue is related to the command: ng serve --locale ar-SA --proxy-config proxy.config.json

after changing it to: ng serve --proxy-config ../proxy.config.json

Things worked fine. Notice also the proxy config are not being found on the root folder but in the src!

AlQuraian avatar Mar 18 '18 13:03 AlQuraian

I get the same error using ng serve --aot=true (worked with 6.0.0-beta.5)

$ ng serve --aot
Schema validation failed with the following errors:
  Data path "" should NOT have additional properties (aot).
Error: Schema validation failed with the following errors:
  Data path "" should NOT have additional properties (aot).
    at MergeMapSubscriber.registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (/Users/benneq/Development/ng6/node_modules/@angular-devkit/architect/src/architect.js:218:39)
    at MergeMapSubscriber._tryNext (/Users/benneq/Development/ng6/node_modules/rxjs/operators/mergeMap.js:122:27)
    at MergeMapSubscriber._next (/Users/benneq/Development/ng6/node_modules/rxjs/operators/mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (/Users/benneq/Development/ng6/node_modules/rxjs/Subscriber.js:90:18)
    at MergeMapSubscriber.notifyNext (/Users/benneq/Development/ng6/node_modules/rxjs/operators/mergeMap.js:145:30)
    at InnerSubscriber._next (/Users/benneq/Development/ng6/node_modules/rxjs/InnerSubscriber.js:23:21)
    at InnerSubscriber.Subscriber.next (/Users/benneq/Development/ng6/node_modules/rxjs/Subscriber.js:90:18)
    at MapSubscriber._next (/Users/benneq/Development/ng6/node_modules/rxjs/operators/map.js:85:26)
    at MapSubscriber.Subscriber.next (/Users/benneq/Development/ng6/node_modules/rxjs/Subscriber.js:90:18)
    at SwitchMapSubscriber.notifyNext (/Users/benneq/Development/ng6/node_modules/rxjs/operators/switchMap.js:126:30)

benneq avatar Mar 18 '18 18:03 benneq

Got the same issue with

ng build --aot -prod --extract-licenses --vendor-chunk --output-hashing=none --build-optimizer
Schema validation failed with the following errors:
  Data path "" should NOT have additional properties (p).
Error: Schema validation failed with the following errors:
  Data path "" should NOT have additional properties (p).
    at MergeMapSubscriber.registry.compile.pipe.operators_1.concatMap.validatorResult [as project] (node_modules/@angular-devkit/architect/src/architect.js:218:39)
    at MergeMapSubscriber._tryNext (node_modules/rxjs/operators/mergeMap.js:122:27)
    at MergeMapSubscriber._next (node_modules/rxjs/operators/mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (node_modules/rxjs/Subscriber.js:90:18)
    at MergeMapSubscriber.notifyNext (node_modules/rxjs/operators/mergeMap.js:145:30)
    at InnerSubscriber._next (node_modules/rxjs/InnerSubscriber.js:23:21)
    at InnerSubscriber.Subscriber.next (node_modules/rxjs/Subscriber.js:90:18)
    at MapSubscriber._next (node_modules/rxjs/operators/map.js:85:26)
    at MapSubscriber.Subscriber.next (node_modules/rxjs/Subscriber.js:90:18)
    at SwitchMapSubscriber.notifyNext (node_modules/rxjs/operators/switchMap.js:126:30)

bvdmitri avatar Mar 19 '18 19:03 bvdmitri

^^^ There is no error with

--target=production --environment=prod

instead of

-prod

bvdmitri avatar Mar 19 '18 19:03 bvdmitri

@bvdmitri - you are correct. I was able to successfully build using --target=production --environment=prod.

etsuo avatar Mar 20 '18 14:03 etsuo

I get the same error running ng serve --proxy-config proxy.conf.json --no-delete-output-path --base-href '/'

MattMorrisDev avatar Mar 20 '18 18:03 MattMorrisDev

@bvdmitri @etsuo --target=production --environment=prod worked but my dev environment was picked up in the final bundle not the prod one !!!

Also when i try --target=production --environment=anyotherenv he is always picking the dev one. Did you have the same issue ?

omahjoub avatar Mar 21 '18 15:03 omahjoub

Using --prod (instead of -prod) solved the problem for me

nielsheeren avatar Mar 21 '18 16:03 nielsheeren

Do you get any errors using ng serve with parameters? e.g. ng serve --aot=true --proxy-config proxy.conf.json?

benneq avatar Mar 21 '18 16:03 benneq

I do: no error when only using "start": "ng serve", in my package.json.

The error appears when I start the same project with parameter "start": "ng serve -p 4201", (no matter which port No.). Didn't try other params.

In all former setups/versions I never had this problem. Looks like at least the existence of parameters in ng-serve causes the problem.

But, when I use --port 4201 instead of -p 4201, the error disappears again. Presumably some syntax change by the developers or abbreviations are not parsed correctly anymore.

Here's my environment: Windows 7, in PhpStorm 2017.3 shell and MINGW64 package.json which produces the error:

 "name": "...",
  "version": "0.0.2",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "lint": "ng lint",
    "pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
    "build": "ng build",
    "start": "ng serve -p 4201",
    "test": "ng test",
    "e2e": "ng e2e",
    "doc": "ng doc"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.0-rc.0",
    "@angular/cdk": "github:angular/cdk-builds",
    "@angular/common": "^6.0.0-rc.0",
    "@angular/compiler": "^6.0.0-rc.0",
    "@angular/core": "^6.0.0-rc.0",
    "@angular/forms": "^6.0.0-rc.0",
    "@angular/http": "^6.0.0-rc.0",
    "@angular/material": "github:angular/material2-builds",
    "@angular/platform-browser": "^6.0.0-rc.0",
    "@angular/platform-browser-dynamic": "^6.0.0-rc.0",
    "@angular/router": "^6.0.0-rc.0",
    "core-js": "^2.5.3",
    "rxjs": "^5.6.0-forward-compat.0 || ^6.0.0-alpha.4",
    "zone.js": "^0.8.20"
  },
  "devDependencies": {
    "rxjs-compat": "^6.0.0-beta.1",
    "@angular/cli": "^6.0.0-beta.6",
    "@angular/compiler-cli": "^6.0.0-rc.0",
    "@angular/language-service": "^6.0.0-rc.0",
    "@types/jasmine": "^2.8.6",
    "@types/jasminewd2": "^2.0.3",
    "@types/node": "^9.4.7",
    "autoprefixer": "^8.1.0",
    "circular-dependency-plugin": "^4.4.0",
    "codelyzer": "^4.2.1",
    "css-loader": "^0.28.11",
    "cssnano": "^3.10.0",
    "exports-loader": "^0.7.0",
    "file-loader": "^1.1.11",
    "html-webpack-plugin": "^3.0.7",
    "istanbul-instrumenter-loader": "^3.0.0",
    "jasmine-core": "~3.1.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": "^0.2.2",
    "less-loader": "^4.1.0",
    "postcss-loader": "^2.1.3",
    "postcss-url": "^7.3.1",
    "protractor": "~5.3.0",
    "raw-loader": "^0.5.1",
    "sass-loader": "^6.0.7",
    "script-loader": "^0.7.2",
    "source-map-loader": "^0.2.3",
    "style-loader": "^0.20.3",
    "stylus-loader": "^3.0.2",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "^2.7.2",
    "url-loader": "^1.0.1",
    "webpack": "~4.2.0",
    "webpack-dev-server": "^3.1.1"
  },
  "main": "index.js",
  "repository": "...",
  "author": "..."
}

volei avatar Mar 22 '18 18:03 volei

@omahjoub yes, I just checked and ng build picks only dev environment. I couldn’t force the cli to pick the proper environment file. Also I realized that in my project “ng build” command is not respecting any parameters in .angular-cli.json file (outDir, deployUrl etc..) and it just picking the default ones. I should manually set this parameters in npm task (ng build —deploy-url=blabla etc). Is it correct behavior for the new version of angular-cli?

bvdmitri avatar Mar 22 '18 19:03 bvdmitri

I now set up a new project and upgraded to the latest dependencies (angular 6.0.0-rc.0, angular cli 6.0.0-beta.6, rxjs 6.0.0-beta.1, rxjs-compat 6.0.0-beta.1).

I encountered following issues with ng serve:

  • doesn't support --aot (this is crucial for development with es2015 output)
  • doesn't support --progress
  • --proxy-config only works with ../proxy.conf.json, before it worked with proxy.conf.json (this bug was also mentioned in this issue before with ng build)

Before that I was using Angular CLI 6.0.0-beta.5 where everything worked fine.

benneq avatar Mar 24 '18 15:03 benneq

I just recently updated to 6.0.0-rc.0 after a dependency was unresolvable in 6.0.0-beta.4 (html-webpack-plugin if anyone is interested). I deleted 'node_modules' and 'dist' as stated in the manual for updating local project package.

But now I cannot build for custom environments anymore.

Whenever I try to run ng build --env=prerelease --target=production it throws

Project 'production' could not be found in workspace.
Error: Project 'production' could not be found in workspace.

When I run ng build --env=prerelease --prod instead it throws

Schema validation failed with the following errors:
Data path "" should NOT have additional properties (env).

Even if I only run ng build --prod I get an error, which is

Cannot read property 'match' of undefined
TypeError: Cannot read property 'match' of undefined
    at Object.normalize (<path-to-app>\node_modules\@angular-devkit\build-angular\node_modules\@angular-devkit\core\src\virtual-fs\path.js:178:14)
    at options.fileReplacements.forEach (<path-to-app>\node_modules\@angular-devkit\build-angular\src\browser\index.js:99:55)
    at Array.forEach (<anonymous>)
    at BrowserBuilder.buildWebpackConfig [...]

Seika85 avatar Apr 03 '18 15:04 Seika85

My upgrade strategy for the last versions was like this:

npm i g @angular/cli@next
ng new foo --next
(merge your old package.json into the new one)
(copy your project files into the new folder)
npm i

This takes about 10-20 minutes, but then you can be sure, that you didn't mess the config up.

Every time I tried to manually "upgrade" the project using ng update and modifying the package.json, something went wrong. Additionally they changed a lot in terms of options and folder layout in the last versions.

benneq avatar Apr 03 '18 15:04 benneq

+1

speige avatar Apr 05 '18 04:04 speige

I was able to fix this on my project by removing the majority of the -- flags from ng build (--aot --sourcemaps --extract-css etc) and instead use --configuration someName and put all the flags inside the angular.json file under the corresponding configuration.

The fact that it's checking schema now is actually pretty cool, because I was previously passing the same flags for ng serve, ng build, & for server build for universal rendering, however some flags aren't actually valid for all 3 types of builds.

speige avatar Apr 05 '18 22:04 speige

Hi all,

In Angular CLI v6 it is by design that arguments only work with the double dash. The correct argument is only --prod, and -prod will not work.

Sorry for the confusion. We will add this to the CLI v6 release announcement so that no one else is surprised by it.

filipesilva avatar May 01 '18 05:05 filipesilva

Hello guyz, i solved it by changing the styleExt attribute to Schematics rule: instead of

...
...
...
 },
  "defaults": {
    "styleExt": "less",** 
    "component": {}
  }

change to

"projects": {
    "delegations": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "del",
      "schematics": {
        "@schematics/angular:component": {
          "styleext": "less"
        }
      },

YaakovHatam avatar May 21 '18 06:05 YaakovHatam

Still facing same error ?

MayarAhmed avatar Jul 31 '18 11:07 MayarAhmed