typescript Angular 依赖性错误[已关闭]

pn9klfpd  于 2023-02-20  发布在  TypeScript
关注(0)|答案(1)|浏览(149)

已关闭。此问题需要details or clarity。当前不接受答案。
**想要改进此问题?**添加详细信息并通过editing this post阐明问题。

昨天关门了。
Improve this question
我在安装npm时遇到了一些问题,它只在我的工作站上工作,而且是在我添加了一个简单的mat-date-picker之后发生的...这是我的package.json,我已经尝试了所有可能的命令苏查如npm install --保存--force等...

{
  "name": "ap-iproj-porto",
  "version": "0.0.1-SNAPSHOT",
  "private": true,
  "description": "Description for APIprojPorto",
  "license": "UNLICENSED",
  "scripts": {
    "app:start": "./mvnw",
    "backend:build-cache": "./mvnw dependency:go-offline",
    "backend:debug": "./mvnw -Dspring-boot.run.jvmArguments=\"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000\"",
    "backend:doc:test": "./mvnw -ntp javadoc:javadoc --batch-mode",
    "backend:info": "./mvnw -ntp enforcer:display-info --batch-mode",
    "backend:nohttp:test": "./mvnw -ntp checkstyle:check --batch-mode",
    "backend:start": "./mvnw -Dskip.installnodenpm -Dskip.npm",
    "backend:unit:test": "./mvnw -ntp -Dskip.installnodenpm -Dskip.npm verify --batch-mode -Dlogging.level.ROOT=OFF -Dlogging.level.org.zalando=OFF -Dlogging.level.tech.jhipster=OFF -Dlogging.level.com.cmporto.api=OFF -Dlogging.level.org.springframework=OFF -Dlogging.level.org.springframework.web=OFF -Dlogging.level.org.springframework.security=OFF",
    "build": "npm run webapp:prod --",
    "build-watch": "concurrently 'npm run webapp:build:dev -- --watch' npm:backend:start",
    "ci:backend:test": "npm run backend:info && npm run backend:doc:test && npm run backend:nohttp:test && npm run backend:unit:test -- -P$npm_package_config_default_environment",
    "ci:e2e:package": "npm run java:$npm_package_config_packaging:$npm_package_config_default_environment -- -Pe2e -Denforcer.skip=true",
    "ci:e2e:prepare": "npm run ci:e2e:prepare:docker",
    "ci:e2e:prepare:docker": "npm run docker:db:up && npm run docker:others:up && docker ps -a",
    "ci:e2e:run": "concurrently -k -s first \"npm run ci:e2e:server:start\" \"npm run e2e:headless\"",
    "preci:e2e:server:start": "npm run docker:db:await --if-present && npm run docker:others:await --if-present",
    "ci:e2e:server:start": "java -jar target/e2e.$npm_package_config_packaging --spring.profiles.active=e2e,$npm_package_config_default_environment -Dlogging.level.ROOT=OFF -Dlogging.level.org.zalando=OFF -Dlogging.level.tech.jhipster=OFF -Dlogging.level.com.cmporto.api=OFF -Dlogging.level.org.springframework=OFF -Dlogging.level.org.springframework.web=OFF -Dlogging.level.org.springframework.security=OFF --logging.level.org.springframework.web=ERROR",
    "ci:e2e:teardown": "npm run ci:e2e:teardown:docker",
    "ci:e2e:teardown:docker": "npm run docker:db:down --if-present && npm run docker:others:down && docker ps -a",
    "ci:frontend:build": "npm run webapp:build:$npm_package_config_default_environment",
    "ci:frontend:test": "npm run ci:frontend:build && npm test",
    "ci:server:await": "echo \"Waiting for server at port $npm_package_config_backend_port to start\" && wait-on -t 180000 http-get://localhost:$npm_package_config_backend_port/management/health && echo \"Server at port $npm_package_config_backend_port started\"",
    "clean-coverage": "rimraf .nyc_output coverage",
    "clean-www": "rimraf target/classes/static/app/{src,target/}",
    "cleanup": "rimraf target/classes/static/",
    "cypress": "cypress open --e2e",
    "docker:app:up": "docker-compose -f src/main/docker/app.yml up -d",
    "docker:db:down": "docker-compose -f src/main/docker/postgresql.yml down -v",
    "docker:db:up": "docker-compose -f src/main/docker/postgresql.yml up -d",
    "docker:elasticsearch:down": "docker-compose -f src/main/docker/elasticsearch.yml down -v",
    "docker:elasticsearch:up": "docker-compose -f src/main/docker/elasticsearch.yml up -d",
    "docker:jhipster-registry:await": "echo \"Waiting for jhipster-registry to start\" && wait-on -t 180000 http-get://localhost:8761/management/health && echo \"jhipster-registry started\"",
    "docker:jhipster-registry:down": "docker-compose -f src/main/docker/jhipster-registry.yml down -v",
    "docker:jhipster-registry:up": "docker-compose -f src/main/docker/jhipster-registry.yml up -d",
    "docker:others:await": "echo \"Waiting for Elasticsearch to start\" && wait-on -t 180000 \"http-get://localhost:9200/_cluster/health?wait_for_status=green&timeout=60s\" && echo \"Elasticsearch started\" && npm run docker:jhipster-registry:await",
    "docker:others:down": "npm run docker:elasticsearch:down && npm run docker:jhipster-registry:down",
    "predocker:others:up": "",
    "docker:others:up": "npm run docker:elasticsearch:up && npm run docker:jhipster-registry:up",
    "e2e": "npm run e2e:cypress:headed --",
    "e2e:cypress": "cypress run --e2e --browser chrome --record ${CYPRESS_ENABLE_RECORD:-false}",
    "pree2e:cypress:coverage": "npm run clean coverage && npm run ci:server:await",
    "e2e:cypress:coverage": "npm run e2e:cypress:headed",
    "poste2e:cypress:coverage": "nyc report",
    "e2e:cypress:headed": "npm run e2e:cypress -- --headed",
    "e2e:dev": "concurrently -k -s first \"./mvnw\" \"npm run e2e\"",
    "e2e:devserver": "concurrently -k -s first \"npm run backend:start\" \"npm start\" \"wait-on -t 180000 http-get://localhost:9000 && npm run e2e:headless -- -c baseUrl=http://localhost:9000\"",
    "pree2e:headless": "npm run ci:server:await",
    "e2e:headless": "npm run e2e:cypress --",
    "java:docker": "./mvnw -ntp verify -DskipTests -Pprod jib:dockerBuild",
    "java:docker:arm64": "npm run java:docker -- -Djib-maven-plugin.architecture=arm64",
    "java:docker:dev": "npm run java:docker -- -Pdev,webapp",
    "java:docker:prod": "npm run java:docker -- -Pprod",
    "java:jar": "./mvnw -ntp verify -DskipTests --batch-mode",
    "java:jar:dev": "npm run java:jar -- -Pdev,webapp",
    "java:jar:prod": "npm run java:jar -- -Pprod",
    "java:war": "./mvnw -ntp verify -DskipTests --batch-mode -Pwar",
    "java:war:dev": "npm run java:war -- -Pdev,webapp",
    "java:war:prod": "npm run java:war -- -Pprod",
    "jest": "jest --coverage --logHeapUsage --maxWorkers=2 --config jest.conf.js",
    "lint": "eslint . --ext .js,.ts",
    "lint:fix": "npm run lint -- --fix",
    "prepare": "husky install",
    "prettier:check": "prettier --check \"{,src/**/,webpack/,.blueprint/**/}*.{md,json,yml,html,cjs,mjs,js,ts,tsx,css,scss,java}\"",
    "prettier:format": "prettier --write \"{,src/**/,webpack/,.blueprint/**/}*.{md,json,yml,html,cjs,mjs,js,ts,tsx,css,scss,java}\"",
    "serve": "npm run start --",
    "start": "ng serve --hmr",
    "start-tls": "npm run webapp:dev-ssl",
    "pretest": "npm run lint",
    "test": "ng test --coverage --log-heap-usage -w=2",
    "test:watch": "npm run test -- --watch",
    "watch": "concurrently npm:start npm:backend:start",
    "webapp:build": "npm run clean-www && npm run webapp:build:dev",
    "webapp:build:dev": "ng build --configuration development",
    "webapp:build:prod": "ng build --configuration production",
    "webapp:dev": "ng serve",
    "webapp:dev-ssl": "ng serve --ssl",
    "webapp:dev-verbose": "ng serve --verbose",
    "prewebapp:instrumenter": "npm run clean-www && npm run clean-coverage",
    "webapp:instrumenter": "ng build --configuration instrumenter",
    "webapp:prod": "npm run clean-www && npm run webapp:build:prod",
    "webapp:test": "npm run test --"
  },
  "config": {
    "backend_port": "8080",
    "default_environment": "prod",
    "packaging": "jar"
  },
  "dependencies": {
    "@angular/animations": "^15.1.1",
    "@angular/cdk": "^14.2.3",
    "@angular/common": "14.2.0",
    "@angular/compiler": "14.2.0",
    "@angular/core": "14.2.0",
    "@angular/forms": "14.2.0",
    "@angular/localize": "14.2.0",
    "@angular/material": "^7.0.0",
    "@angular/platform-browser": "14.2.0",
    "@angular/platform-browser-dynamic": "14.2.0",
    "@angular/router": "14.2.0",
    "@fortawesome/angular-fontawesome": "0.11.1",
    "@fortawesome/fontawesome-svg-core": "6.2.0",
    "@fortawesome/free-solid-svg-icons": "6.2.0",
    "@ng-bootstrap/ng-bootstrap": "13.0.0",
    "@ngx-translate/core": "14.0.0",
    "@ngx-translate/http-loader": "7.0.0",
    "@popperjs/core": "2.11.6",
    "@types/leaflet": "^1.9.0",
    "angular-material-clock-time-picker": "0.0.12",
    "bootstrap": "5.2.0",
    "bootswatch": "5.2.0",
    "dayjs": "1.11.5",
    "leaflet": "^1.9.3",
    "lodash": "^4.17.21",
    "mat-timepicker": "^5.1.8",
    "material": "^0.5.2",
    "ngx-infinite-scroll": "14.0.0",
    "ngx-webstorage": "10.0.1",
    "papaparse": "^5.3.2",
    "requests": "^0.3.0",
    "rxjs": "7.5.6",
    "tslib": "2.4.0",
    "zone.js": "0.11.6"
  },
  "devDependencies": {
    "@angular-builders/custom-webpack": "14.0.1",
    "@angular-builders/jest": "14.0.1",
    "@angular-devkit/build-angular": "14.2.1",
    "@angular-eslint/eslint-plugin": "14.0.3",
    "@angular/cli": "14.2.1",
    "@angular/compiler-cli": "14.2.0",
    "@angular/service-worker": "14.2.0",
    "@cypress/code-coverage": "3.10.0",
    "@types/jest": "28.1.8",
    "@types/node": "16.11.56",
    "@types/papaparse": "^5.3.7",
    "@typescript-eslint/eslint-plugin": "5.36.1",
    "@typescript-eslint/parser": "5.36.1",
    "babel-loader": "8.2.5",
    "babel-plugin-istanbul": "6.1.1",
    "browser-sync": "^2.27.11",
    "browser-sync-webpack-plugin": "2.3.0",
    "concurrently": "7.3.0",
    "copy-webpack-plugin": "11.0.0",
    "cypress": "10.7.0",
    "eslint": "8.23.0",
    "eslint-config-prettier": "8.5.0",
    "eslint-plugin-cypress": "2.12.1",
    "eslint-webpack-plugin": "3.2.0",
    "folder-hash": "4.0.2",
    "generator-jhipster": "7.9.3",
    "husky": "7.0.4",
    "jest": "28.1.3",
    "jest-date-mock": "1.0.8",
    "jest-environment-jsdom": "28.1.3",
    "jest-junit": "14.0.1",
    "jest-preset-angular": "12.2.2",
    "jest-sonar": "0.2.12",
    "lint-staged": "13.0.3",
    "merge-jsons-webpack-plugin": "2.0.1",
    "nyc": "15.1.0",
    "prettier": "2.7.1",
    "prettier-plugin-java": "1.6.2",
    "prettier-plugin-packagejson": "2.2.18",
    "rimraf": "3.0.2",
    "swagger-ui-dist": "4.14.0",
    "ts-jest": "28.0.8",
    "typescript": "4.8.2",
    "wait-on": "6.0.1",
    "webpack-bundle-analyzer": "4.6.1",
    "webpack-merge": "5.8.0",
    "webpack-notifier": "1.15.0"
  },
  "engines": {
    "node": ">=16.17.0"
  },
  "cacheDirectories": [
    "node_modules"
  ],
  "overrides": {
    "webpack": "5.74.0"
  }
}
  • 我尝试删除node_modules并键入npm install -我尝试在其他PC上运行npm install --保存--force,但不起作用-我尝试npm cache clean --force
    我的:npm列表npm command list
ylamdve6

ylamdve61#

您得到错误是因为您有不兼容的依赖项。
在您的package.json中,您定义了@angular/material版本7.0.0,但此版本仅与Angular 7兼容。然后,15.1.1版本中有@angular/animations,但此版本需要版本15中的Angular。此外,mat-timepicker需要版本14中的@angular/material
尝试安装正确版本的@angular/animations@angular/material

npm i @angular/animations@14 @angular/material@14

您可能需要使用--force标志运行npm install。
package.json的以下更改应解决所有对等依赖警告和错误(* 仅包括更改的行 *)。当前的主要问题是mat-timepicker的对等依赖。这些依赖非常严格,请参见mat-timepicker的源代码。还有an open issue解决了此问题。

"dependencies": {
  "@angular/animations": "^14.1.0",
  "@angular/cdk": "14.1.3",
  "@angular/common": "^14.1.0",
  "@angular/compiler": "^14.1.0",
  "@angular/core": "^14.1.0",
  "@angular/forms": "^14.1.0",
  "@angular/localize": "^14.1.0",
  "@angular/material": "14.1.3",
  "@angular/platform-browser": "^14.1.0",
  "@angular/platform-browser-dynamic": "^14.1.0",
  "@angular/router": "^14.1.0"
},
"devDependencies": {
  "@angular/compiler-cli": "^14.1.0",
  "@angular/service-worker": "^14.1.0"
}

将这些更改应用于package.json后,运行npm update
新版本的@angular/material可能需要一些调整才能正常工作。版本7于2018年发布。随着七个主要版本的发布,你可以期待一些突破性的变化。
This blog post has also some information有关对等依赖关系以及出现这些问题的原因。

相关问题