[英]npm install not working in angular project
Runnig npm install
command is giving errors. npm install
命令出现错误。
THE ERROR:错误:
``
PS D:\t> npm install
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: public_services@1.0.0
npm ERR! Found: typescript@4.9.4
npm ERR! node_modules/typescript
npm ERR! dev typescript@"~4.9.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer typescript@">=4.8.2 <4.9" from @angular/compiler-cli@15.0.4
npm ERR! node_modules/@angular/compiler-cli
npm ERR! dev @angular/compiler-cli@"~15.0.4" from the root project
npm ERR! peer @angular/compiler-cli@"15.0.4" from @angular/localize@15.0.4
npm ERR! node_modules/@angular/localize
npm ERR! dev @angular/localize@"^15.0.4" from the root project
npm ERR! 1 more (@ng-bootstrap/ng-bootstrap)
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! See C:\Users\sayed.hussainullah\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sayed.hussainullah\AppData\Local\npm-cache\_logs\2023-01-11T06_57_30_299Z-debug-0.log
``
Global angular version:全局 angular 版本:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 15.0.5
Node: 16.16.0
Package Manager: npm 8.17.0
OS: win32 x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.1500.5 (cli-only)
@angular-devkit/core 15.0.5 (cli-only)
@angular-devkit/schematics 15.0.5 (cli-only)
@schematics/angular 15.0.5 (cli-only)
Package.json file: Package.json 文件:
{
"name": "public_services",
"version": "1.0.0",
"license": "",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~15.0.4",
"@angular/cdk": "^15.0.4",
"@angular/common": "~15.0.4",
"@angular/compiler": "~15.0.4",
"@angular/core": "~15.0.4",
"@angular/forms": "~15.0.4",
"@angular/platform-browser": "~15.0.4",
"@angular/platform-browser-dynamic": "~15.0.4",
"@angular/router": "15.0.4",
"@fortawesome/angular-fontawesome": "^0.12.1",
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-brands-svg-icons": "^6.2.1",
"@fortawesome/free-regular-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"@ng-bootstrap/ng-bootstrap": "14.0.1",
"@ng-select/ng-select": "^10.0.3",
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "7.0.0",
"@swimlane/ngx-datatable": "^20.1.0",
"angular-archwizard": "7.0.0",
"angular-feather": "^6.5.0",
"bootstrap": "5.2.3",
"chart.js": "^4.1.2",
"classlist.js": "1.1.20150312",
"core-js": "3.27.1",
"date-fns": "2.29.3",
"gulp": "4.0.2",
"hopscotch": "0.3.1",
"intl": "1.2.5",
"moment": "2.29.4",
"ng-lazyload-image": "^9.1.3",
"ng2-charts": "^4.1.1",
"ng2-file-upload": "3.0.0",
"ng2-img-cropper": "0.9.0",
"ng2-jalali-date-picker": "^2.2.8",
"ngx-bootstrap": "^10.2.0",
"ngx-chips": "3.0.0",
"ngx-datatable": "^1.0.3",
"ngx-dropzone-wrapper": "^13.0.0",
"ngx-perfect-scrollbar": "^7.2.1",
"ngx-toastr": "16.0.2",
"node-sass": "^8.0.0",
"nouislider": "15.6.1",
"prismjs": "1.29.0",
"resize-observer-polyfill": "1.5.1",
"rxjs": "7.8.0",
"screenfull": "6.0.2",
"sweetalert2": "11.6.16",
"tslib": "^2.4.1",
"web-animations-js": "^2.3.2",
"xlsx": "^0.18.5",
"zone.js": "~0.12.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "~15.0.5",
"@angular/cli": "~15.0.5",
"@angular/compiler-cli": "~15.0.4",
"@angular/language-service": "~15.0.4",
"@angular/localize": "^15.0.4",
"@types/core-js": "2.5.5",
"@types/jasmine": "^4.3.1",
"@types/jasminewd2": "~2.0.10",
"@types/jquery": "^3.5.16",
"@types/node": "^18.11.18",
"codelyzer": "^6.0.2",
"jasmine-core": "~4.5.0",
"jasmine-spec-reporter": "~7.0.0",
"karma": "~6.4.1",
"karma-chrome-launcher": "~3.1.1",
"karma-cli": "~2.0.0",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "^2.0.0",
"protractor": "~7.0.0",
"rxjs-compat": "6.6.7",
"ts-node": "~10.9.1",
"tslint": "~6.1.0",
"typescript": "~4.9.4"
}
}
I have tried:我努力了:
so far non-of these methods worked到目前为止,这些方法都没有奏效
You should try running npm install --legacy-peer-deps
, in order to ignore dependencies between packages.您应该尝试运行
npm install --legacy-peer-deps
,以忽略包之间的依赖关系。 Nevertheless the root cause of your problem is that your installed angular versions expects typescript version >=4.8.2 and <4.9, but 4.9.4 will be installed.尽管如此,您问题的根本原因是您安装的 angular 版本需要 typescript 版本 >=4.8.2 和 <4.9,但将安装 4.9.4。 So a solution might be to downgrade your typescript version or update your angular versions.
因此,解决方案可能是降级 typescript 版本或更新 angular 版本。
There are limitations of npm's Install Algorithm, So npm
will refuse to install any package with an identical name to the current package. It will overridden with the --force
flag, but in most cases can simply be addressed by changing the local package name. npm 的安装算法存在局限性,因此
npm
将拒绝安装任何与当前 package 具有相同名称的 package。它将被--force
标志覆盖,但在大多数情况下可以通过更改本地 package 名称来解决。
So you need to use --force
flag to re-install packages again like below:因此,您需要使用
--force
标志再次重新安装软件包,如下所示:
npm install --force
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.