angularjs 如何修复破坏代码的依赖更新

i7uq4tfw  于 2023-06-21  发布在  Angular
关注(0)|答案(2)|浏览(151)

我的代码停止运行,一旦我更新了一个依赖关系,它给予了我一个错误,坚持无论什么
在我在我的项目中运行ng serve后,代码通常可以工作,但一旦我更新了chartist,它就给了我这个错误:在此输入

An unhandled exception occurred: Directory import 'C:\Users\Adam\Desktop\Dashboard admin\material-dashboard-angular2-master\node_modules\@angular-devkit\build-angular\src\dev-server' is not supported resolving ES modules imported from C:\Users\Adam\Desktop\Dashboard admin\material-dashboard-angular2-master\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
Did you mean to import C:/Users/Adam/Desktop/Dashboard admin/material-dashboard-angular2-master/node_modules/@angular-devkit/build-angular/src/dev-server/index.js?
See "C:\Users\Adam\AppData\Local\Temp\ng-6Ov2p1\angular-errors.log" for further details.

我试着在我的终端上运行npm安装,但我得到了这个

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @angular-devkit/build-angular@0.1002.1
npm ERR! Found: @angular/compiler-cli@14.3.0
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   dev @angular/compiler-cli@"^14.2.0" from the root project
npm ERR!   peer @angular/compiler-cli@"14.3.0" from @angular/localize@14.3.0
npm ERR!   node_modules/@angular/localize
npm ERR!     @angular/localize@"^14.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler-cli@"^10.0.0" from @angular-devkit/build-angular@0.1002.1
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"^0.1002.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/compiler-cli@10.2.5
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^10.0.0" from @angular-devkit/build-angular@0.1002.1
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"^0.1002.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\Adam\AppData\Local\npm-cache\_logs\2023-06-09T12_05_16_553Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Adam\AppData\Local\npm-cache\_logs\2023-06-09T12_05_16_553Z-debug-0.log

这是我的Package.json文件:

{
    "name": "material-dashboard-angular",
    "version": "2.8.0",
    "license": "MIT",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e",
        "install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && ng serve -o"
    },
    "engines": {
        "node": "6.11.1",
        "npm": "3.10.9"
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "^14.2.0",
        "@angular/cdk": "^14.2.0",
        "@angular/common": "^14.2.0",
        "@angular/compiler": "^14.2.0",
        "@angular/core": "^14.2.0",
        "@angular/elements": "^14.2.0",
        "@angular/forms": "^14.2.0",
        "@angular/localize": "^14.2.0",
        "@angular/material": "^14.2.0",
        "@angular/platform-browser": "^14.2.0",
        "@angular/platform-browser-dynamic": "^14.2.0",
        "@angular/router": "^14.2.0",
        "ajv": "8.11.0",
        "arrive": "2.4.1",
        "bootstrap": "4.6.1",
        "bootstrap-material-design": "4.1.3",
        "bootstrap-notify": "3.1.3",
        "chartist": "^0.11.4",
        "chartist-plugin-tooltip": "^0.0.11",
        "classlist.js": "1.1.20150312",
        "eslint": "^8.11.0",
        "express": "4.17.3",
        "googleapis": "99.0.0",
        "hammerjs": "2.0.8",
        "jquery": "3.6.0",
        "moment": "^2.29.4",
        "perfect-scrollbar": "1.5.5",
        "popper.js": "1.16.1",
        "rxjs": "~7.5.0",
        "tslib": "^2.3.0",
        "web-animations-js": "2.3.2",
        "zone.js": "~0.11.4"
    },
    "devDependencies": {
        "@angular-devkit/build-angular": "^0.1002.1",
        "@angular/cli": "~14.2.7",
        "@angular/compiler-cli": "^14.2.0",
        "@angular/language-service": "14.2.0",
        "@types/bootstrap": "4.5.0",
        "@types/chartist": "0.11.1",
        "@types/google.maps": "3.47.4",
        "@types/jasmine": "~4.0.0",
        "@types/jasminewd2": "~2.0.10",
        "@types/jquery": "3.5.6",
        "@types/node": "^17.0.21",
        "codelyzer": "^0.0.28",
        "jasmine-core": "~4.4.0",
        "jasmine-spec-reporter": "~7.0.0",
        "karma": "~6.4.0",
        "karma-chrome-launcher": "~3.1.0",
        "karma-coverage": "~2.2.0",
        "karma-coverage-istanbul-reporter": "~3.0.3",
        "karma-jasmine": "~5.1.0",
        "karma-jasmine-html-reporter": "~2.0.0",
        "protractor": "^3.3.0",
        "sass": "1.32.13",
        "ts-node": "~10.9.1",
        "typescript": "~4.7.2"
    }
}
txu3uszq

txu3uszq1#

您可以运行命令npm install --force(如错误消息所示)或npm clean-install来重新创建整个node_modules文件夹。
请在你做之前备份所有的东西。;)

ubof19bj

ubof19bj2#

在项目上尝试npm ci。这将是一个干净的安装。

相关问题