数据路径“”不应具有附加属性(allowedCommonJsDependencies)

Seb*_*Sky 8 npm .net-core angular

我正在使用 Angular v10,但在启动我的 .net core / Angular 应用程序时遇到问题。

我一直在尝试寻找解决方案/甚至将所有内容都升级到最新版本,但仍然无法正常工作。

当我运行 ng build --watch 时,它没有以任何错误结束,但是当我从 Visual Studio 启动我的应用程序时,我最终在浏览器中出现了这样的错误:

Un unhandled exception occurred while processing the request.
AggregateException: One or more errors occurred. (One or more errors occurred. (The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Schema validation failed with the following errors:

Data path "" should NOT have additional properties(allowedCommonJsDependencies).

npm ERR! code ELIFECYCLE

npm ERR! errno 1
npm ERR! fuse@10.0.0 start: `ng serve --open "--port" "53931"`

npm ERR! Exit status 1

npm ERR!
npm ERR! Failed at the fuse@10.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


npm ERR! A complete log of this run can be found in:

))

System.Threading.Tasks.Task.ThrowIfExceptional(bool includeTaskCanceledExceptions)
InvalidOperationException: The NPM script 'start' exited without indicating that the Angular CLI was listening for requests. The error output was: Schema validation failed with the following errors:

Data path "" should NOT have additional properties(allowedCommonJsDependencies).

npm ERR! code ELIFECYCLE

npm ERR! errno 1
npm ERR! fuse@10.0.0 start: `ng serve --open "--port" "53931"`

npm ERR! Exit status 1

npm ERR!
npm ERR! Failed at the fuse@10.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


npm ERR! A complete log of this run can be found in:
Run Code Online (Sandbox Code Playgroud)

我的配置是:

{
  "name": "fuse",
  "version": "10.0.0",
  "license": "https://themeforest.net/licenses/terms/regular",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --open",
    "start:mem": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng serve --open",
    "build": "ng build",
    "build:prod": "ng build --prod",
    "build:prod:mem": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "bundle-report": "webpack-bundle-analyzer dist/stats.json"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "3.0.0-beta.0",
    "@angular-devkit/build-angular": "0.1000.7",
    "@angular/animations": "10.0.9",
    "@angular/cdk": "10.1.3",
    "@angular/common": "10.0.9",
    "@angular/compiler": "10.0.9",
    "@angular/core": "10.0.9",
    "@angular/flex-layout": "10.0.0-beta.32",
    "@angular/forms": "10.0.9",
    "@angular/material": "10.1.3",
    "@angular/material-moment-adapter": "10.1.3",
    "@angular/platform-browser": "10.0.9",
    "@angular/platform-browser-dynamic": "10.0.9",
    "@angular/router": "10.0.9",
    "@ngrx/effects": "10.0.0",
    "@ngrx/router-store": "10.0.0",
    "@ngrx/store": "10.0.0",
    "@ngrx/store-devtools": "10.0.0",
    "@ngx-translate/core": "13.0.0",
    "@swimlane/dragula": "3.8.0",
    "@swimlane/ngx-charts": "14.0.0",
    "@swimlane/ngx-datatable": "17.1.0",
    "@swimlane/ngx-dnd": "8.2.0",
    "@types/prismjs": "1.16.1",
    "angular-calendar": "0.28.16",
    "angular-in-memory-web-api": "0.11.0",
    "chart.js": "2.9.3",
    "chokidar": "3.4.2",
    "classlist.js": "1.1.20150312",
    "d3": "5.16.0",
    "date-fns": "2.15.0",
    "devextreme": "20.1.6",
    "devextreme-angular": "20.1.6",
    "devextreme-cldr-data": "^1.0.2",
    "devextreme-schematics": "^1.0.12",
    "lodash": "4.17.19",
    "moment": "2.27.0",
    "ng2-charts": "2.3.3",
    "ngrx-store-freeze": "0.2.4",
    "ngx-color-picker": "10.0.1",
    "ngx-cookie-service": "10.0.1",
    "perfect-scrollbar": "1.5.0",
    "prismjs": "1.21.0",
    "rxjs": "6.6.2",
    "tslib": "^2.0.0",
    "web-animations-js": "2.3.2",
    "zone.js": "0.10.3"
  },
  "devDependencies": {
    "@angular/cli": "10.0.5",
    "@angular/compiler-cli": "10.0.9",
    "@angular/language-service": "10.0.9",
    "@types/googlemaps": "3.39.12",
    "@types/jasmine": "3.5.12",
    "@types/jasminewd2": "2.0.8",
    "@types/lodash": "4.14.159",
    "@types/node": "14.0.27",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "8.10.2",
    "tslint": "~6.1.0",
    "typescript": "3.9.7",
    "webpack-bundle-analyzer": "3.8.0"
  }
}
Run Code Online (Sandbox Code Playgroud)

我的角度配置是:

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "fuse": {
            "projectType": "application",
            "schematics": {
                "@schematics/angular:component": {
                    "style": "scss"
                }
            },
            "root": "",
            "sourceRoot": "src",
            "prefix": "app",
            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:browser",
                    "options": {
                        "aot": true,
                        "outputPath": "dist/fuse",
                        "index": "src/index.html",
                        "main": "src/main.ts",
                        "polyfills": "src/polyfills.ts",
                        "tsConfig": "tsconfig.app.json",
                        "assets": [
                            "src/favicon.ico",
                            "src/assets",
                            "src/app/main/angular-material-elements"
                        ],
                        "styles": [
                            "node_modules/devextreme/dist/css/dx.common.css",
                            "node_modules/devextreme/dist/css/dx.light.css",
                            "src/styles.scss"
                        ],
                        "scripts": [],
                        "showCircularDependencies": false,
                        "allowedCommonJsDependencies": [
                            "lodash",
                            "@swimlane/dragula",
                            "chart.js",
                            "angular-calendar",
                            "calendar-utils/date-adapters/date-fns",
                            "contra/emitter",
                            "crossvent",
                            "dom-plane",
                            "dom-set",
                            "@mattlewis92/dom-autoscroller",
                            "devextreme",
                            "devextreme-angular"
                        ]
                    },
                    "configurations": {
                        "production": {
                            "fileReplacements": [
                                {
                                    "replace": "src/environments/environment.ts",
                                    "with": "src/environments/environment.prod.ts"
                                }
                            ],
                            "optimization": true,
                            "outputHashing": "all",
                            "sourceMap": false,
                            "extractCss": true,
                            "namedChunks": false,
                            "aot": true,
                            "extractLicenses": true,
                            "vendorChunk": false,
                            "buildOptimizer": true,
                            "budgets": [
                                {
                                    "type": "initial",
                                    "maximumWarning": "4mb",
                                    "maximumError": "6mb"
                                },
                                {
                                    "type": "anyComponentStyle",
                                    "maximumWarning": "6kb"
                                }
                            ]
                        },
                        "ec": {
                            "budgets": [
                                {
                                    "type": "anyComponentStyle",
                                    "maximumWarning": "6kb"
                                }
                            ],
                            "sourceMap": true,
                            "extractCss": true
                        },
                        "hmr": {
                            "budgets": [
                                {
                                    "type": "anyComponentStyle",
                                    "maximumWarning": "6kb"
                                }
                            ],
                            "fileReplacements": [
                                {
                                    "replace": "src/environments/environment.ts",
                                    "with": "src/environments/environment.hmr.ts"
                                }
                            ]
                        }
                    }
                },
                "serve": {
                    "builder": "@angular-devkit/build-angular:dev-server",
                    "options": {
                        "browserTarget": "fuse:build",
                         "allowedCommonJsDependencies": [
        "lodash"
     ]
                    },
                    "configurations": {
                        "production": {
                            "browserTarget": "fuse:build:production"
                        },
                        "hmr": {
                            "hmr": true,
                            "browserTarget": "fuse:build:hmr"
                        },
                        "ec": {
                            "browserTarget": "fuse:build:ec"
                        }
                    }
                },
                "extract-i18n": {
                    "builder": "@angular-devkit/build-angular:extract-i18n",
                    "options": {
                        "browserTarget": "fuse:build"
                    }
                },
                "test": {
                    "builder": "@angular-devkit/build-angular:karma",
                    "options": {
                        "main": "src/test.ts",
                        "polyfills": "src/polyfills.ts",
                        "tsConfig": "tsconfig.spec.json",
                        "karmaConfig": "karma.conf.js",
                        "assets": [
                            "src/favicon.ico",
                            "src/assets"
                        ],
                        "styles": [
                            "src/styles.scss"
                        ],
                        "scripts": []
                    }
                },
                "lint": {
                    "builder": "@angular-devkit/build-angular:tslint",
                    "options": {
                        "tsConfig": [
                            "tsconfig.app.json",
                            "tsconfig.spec.json",
                            "e2e/tsconfig.json"
                        ],
                        "exclude": [
                            "**/node_modules/**",
                            "**/src/app/fake-db/**/*",
                            "**/src/assets/angular-material-examples/**/*"
                        ]
                    }
                },
                "e2e": {
                    "builder": "@angular-devkit/build-angular:protractor",
                    "options": {
                        "protractorConfig": "e2e/protractor.conf.js",
                        "devServerTarget": "fuse:serve"
                    },
                    "configurations": {
                        "production": {
                            "devServerTarget": "fuse:serve:production"
                        }
                    }
                }
            }
        }
    },
    "defaultProject": "fuse"
}
Run Code Online (Sandbox Code Playgroud)

cha*_*ite 4

我遇到过同样的问题。我通过更新“@angular-builders/custom-webpack”解决了这个问题

  • 需要明确的是,这需要与您的 Angular 版本匹配,因此如果您的版本 v13,您需要 `@angular-builders/custom-webpack@^13.0.0` (2认同)