First-off, I am new to NodeJs and NPM so thanks in advance for any clarification that anyone can offer me.
This is a question about peer dependencies and warnings given by NPM during package installs. The NPM docs and other questions on StackOverflow don't seem to answer my exact questions about what I can/should do to resolved these dependency issues.
Actually, Everything I have tried seems to have made things worse I am now completely confused.
Starting from a fresh install of the latest Angular CLI I created a new Angular 5 project. To this I have added Angular Material.
When I added Angular flex-layout I got the following warnings:
npm WARN #angular/flex-layout#2.0.0-beta.10-4905443 requires a peer of #angular/core#~4.4.4 but none is installed. You must install peer dependencies yourself.
npm WARN #angular/flex-layout#2.0.0-beta.10-4905443 requires a peer of #angular/common#~4.4.4 but none is installed. You must install peer dependencies yourself.
Adding angular-split adds the following:
npm WARN angular-split#0.2.7 requires a peer of #angular/common#^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular-split#0.2.7 requires a peer of #angular/core#^4.0.0 but none is installed. You must install peer dependencies yourself.
I have done some successful experiments with angular-layout but angular-split does not seem to be working correctly. The examples on the author's website are fine so I suspect that this might be because it doesn't have the Angular version it is expecting.
Do these warnings imply that I can install the required versions of Angular components side-by-side with the primary versions used by my code to satisfy these libraries' requirements?
Alternatively, do they really mean that flex-layout and angular-split are not fully compatible with the version of Angular that I am using (and therefore I can't use them until they are updated).
In summary, can different versions of the same module co-exist in a project, and if so, what steps do I need to take because all I have done so far is get myself in a dreadful mess.
This is what my packages.json file looks like:
{
"name": "angular-test4",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.0.0",
"#angular/cdk": "^5.0.0-rc.2",
"#angular/common": "^5.0.0",
"#angular/compiler": "^5.0.0",
"#angular/core": "^5.0.3",
"#angular/flex-layout": "^2.0.0-beta.10-4905443",
"#angular/forms": "^5.0.0",
"#angular/http": "^5.0.0",
"#angular/material": "^5.0.0-rc.2",
"#angular/platform-browser": "^5.0.0",
"#angular/platform-browser-dynamic": "^5.0.0",
"#angular/router": "^5.0.0",
"angular-split": "^0.2.7",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"#angular/cli": "1.5.4",
"#angular/compiler-cli": "^5.0.0",
"#angular/language-service": "^5.0.0",
"#types/jasmine": "~2.5.53",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
}
Related
I got error regarding peer dependencies when I try to install package.json using "npm install".
Peer Dependency error
I have learned that I can use "npm install -legacy-peer-deps" from this link What does npm install --legacy-peer-deps do exactly? When is it recommended / What's a potential use case?.
But I know that "npm install --legacy-peer-deps" ignores peer dependencies so I am looking for different solutions for this error that I attached screenshot. I have tried to define "peerDependencies" in package.json to prevent dependency error but the different versions of the same package are shown as a dependency as shown below screenshot.
different versions of peer dependency
My package.json are shown as below. Would you help me about this problem? What do you suggest for peer dependency problems? When I want to add new packages to package.json, I will face the peer dependency problem again. Thanks.
{
"name": "metric-tutorial",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"#angular/animations": "~13.3.0",
"#angular/cdk": "^13.3.9",
"#angular/common": "~13.3.0",
"#angular/compiler": "~13.3.0",
"#angular/core": "~13.3.0",
"#angular/forms": "~13.3.0",
"#angular/material": "^13.3.9",
"#angular/platform-browser": "~13.3.0",
"#angular/platform-browser-dynamic": "~13.3.0",
"#angular/router": "~13.3.0",
"angular-material-fileupload": "^3.0.2",
"mathjax-angular": "^1.4.2",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "~13.3.1",
"#angular/cli": "~13.3.1",
"#angular/compiler-cli": "~13.3.0",
"#types/jasmine": "~3.10.0",
"#types/node": "^12.11.1",
"angular-cli-ghpages": "^1.0.0",
"jasmine-core": "~4.0.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.1.0",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.6.2"
}
}
so I got a new pc and I wanted to pass my angular project through github.
I used 1.npm i 2.npm i #angular/cli#latest -D 3. ng update
And Everytime I'm trying to run the project with ng s it keeps sending me this error:
This version of CLI is only compatible with Angular versions ^9.0.0-beta || >=9.0.0 <10.0.0,
but Angular version 8.2.14 was found instead.
Please visit the link below to find instructions on how to update Angular.
https://angular-update-guide.firebaseapp.com/
I tried using the instructions at the link.
This is my Angular version when typing ng --version:
Angular CLI: 9.0.1
Node: 12.16.0
This is the package.json:
{
"name": "empire-gaming",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular-redux/store": "^10.0.0",
"#angular/animations": "~8.2.14",
"#angular/cdk": "~8.2.3",
"#angular/common": "~8.2.14",
"#angular/compiler": "~8.2.14",
"#angular/core": "~8.2.14",
"#angular/forms": "~8.2.14",
"#angular/material": "^8.2.3",
"#angular/platform-browser": "~8.2.14",
"#angular/platform-browser-dynamic": "~8.2.14",
"#angular/router": "~8.2.14",
"#ng-bootstrap/ng-bootstrap": "^5.2.1",
"#ngrx/store": "^8.6.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"hammerjs": "^2.0.8",
"mongoose": "^5.8.10",
"ngx-bootstrap": "^5.3.2",
"redux": "^4.0.5",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.803.22",
"#angular/cli": "^9.0.1",
"#angular/compiler-cli": "~8.2.14",
"#angular/language-service": "~8.2.14",
"#types/jasmine": "~3.3.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3"
}
}
I'm really clueless about it... I would be glad if you help me.
The version of Angular that you are using in the project is lower than the version that needed for the latest version of Angular CLI.
I would recommend you to downgrade the Angular CLI version to 8.3.25
npm uninstall -g #angular/cli
npm cache clean
npm install -g #angular/cli#8.3.25
And change the version of Angular CLI in your devDependencies:
npm install -D #angular/cli#8.3.25
First step install Angular globally.
npm install -g #angular/cli#latest
Run Update command to get a list of all dependencies required to be upgraded.
ng update
Next Run update command as below for each individual Angular core package
ng update #angular/cli #angular/core
If you want to force the changes use: –force and –allow-dirty flags command additionally to fix all other pending issues.
ng update #angular/cli #angular/core --allow-dirty --force
This is worked for me
Delete folder node_modules and package-lock.json
then execute: "npm install"
in short:
go to project directory in terminal/command prompt and execute following commands
rm -fr ./node_modules
rm -fr ./package-lock.json
npm install
ng serve -o
I know this is an old thread, but in my experience changing the app package.json file("#angular-devkit/build-angular") to another compatible version works for me :). After the file change, you will be needed to run again these commands "ng update", "npm install" & "ng server"
I'm pulling our code down from our repository to a new laptop. Our project was built on Angular 5 last year. Of course, the new laptop has the latest and greatest Angular CLI, NodeJS, and NPM tools install, and Angular 6 was just released. The laptop has Node 8.11.2, NPM 5.6.0, and Angular CLI 6.0.3.
When I run "npm install" to get the "node_modules" folder on my new laptop for this project, I'm getting all kinds of errors and warnings and unable to create the node_modules folder successfully (see image attached). What can I do to get this project running. I don't necessarily care about upgrading to Angular 6 at this time. I simply need to continue to be able to run and develop this project.
Our package.json:
{
"name": "my-first-app",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --environment=local --open",
"build": "ng build --prod aot=false",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.2.0",
"#angular/cdk": "^5.2.4",
"#angular/common": "^5.2.0",
"#angular/compiler": "^5.2.0",
"#angular/core": "^5.2.0",
"#angular/forms": "^5.2.0",
"#angular/http": "^5.2.0",
"#angular/material": "^5.2.4",
"#angular/platform-browser": "^5.2.0",
"#angular/platform-browser-dynamic": "^5.2.0",
"#angular/router": "^5.2.0",
"#ngui/map": "^0.20.2",
"#types/googlemaps": "^3.30.7",
"bootstrap": "^4.0.0",
"core-js": "^2.4.1",
"google-maps-coords": "^1.0.0",
"jquery": "^3.3.1",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"#angular/cli": "~1.7.1",
"#angular/compiler-cli": "^5.2.0",
"#angular/language-service": "^5.2.0",
"#types/jasmine": "~2.8.3",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"font-awesome": "^4.7.0",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}
I faced a similar issue and removing the package-lock.json and running npm install solved it for me.
First Clean the cache
npm cache clean --force
Then Install It
npm install
It is actually very simple. Just do a sudo npm install node_modules if you are using Mac/Linux or just a npm install node_modules on windows.
I am getting the following error while running the angular4 existing project in my system.
Error:
subrajyoti#subrajyoti-H81M-S:/var/www/html/angular4_project/XSS-DOM/vulnerable$ ng serve
As a forewarning, we are moving the CLI npm package to "#angular/cli" with the next release,
which will only support Node 6.9 and greater. This package will be officially deprecated
shortly after.
To disable this warning use "ng set --global warnings.packageDeprecation=false".
You have to be inside an angular-cli project in order to use the serve command.
I have installed node version 9.4.0 and npm version 5.6.0 and installed the angular cli like this sudo npm install #angular/cli. There was a existing project when I run this project by typing the command ng serve it gave me the above error. I have already inside the project folder but still getting this error. my package.json file is given below.
{
"name": "crud-project",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.2.0",
"#angular/common": "^5.2.0",
"#angular/compiler": "^5.2.0",
"#angular/core": "^5.2.0",
"#angular/forms": "^5.2.0",
"#angular/http": "^5.2.0",
"#angular/platform-browser": "^5.2.0",
"#angular/platform-browser-dynamic": "^5.2.0",
"#angular/router": "^5.2.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"#angular/cli": "1.6.8",
"#angular/compiler-cli": "^5.2.0",
"#angular/language-service": "^5.2.0",
"#types/jasmine": "~2.8.3",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}
Please help me to resolve this error.
You are using a very old unsupported version of the CLI. You should update the the latest one or you can migrate it as described here if you have existing project
I'm at the moment upgrading from Angular 4 to Angular 5 and received some warnings after that, for example:
npm WARN #angular/compiler-cli#5.0.1 requires a peer of typescript#>=2.4.2 <2.5 but none is installed. You must install peer dependencies yourself.
npm WARN #covalent/core#1.0.0-beta.8-1 requires a peer of #angular/common#^4.4.3 but none is installed. You must install peer dependencies yourself.
npm WARN #covalent/core#1.0.0-beta.8-1 requires a peer of #angular/core#^4.4.3 but none is installed. You must install peer dependencies yourself.
npm WARN #covalent/core#1.0.0-beta.8-1 requires a peer of #angular/forms#^4.4.3 but none is installed. You must install peer dependencies yourself.
npm WARN #covalent/core#1.0.0-beta.8-1 requires a peer of #angular/http#^4.4.3 but none is installed. You must install peer dependencies yourself.
npm WARN #covalent/core#1.0.0-beta.8-1 requires a peer of #angular/router#^4.4.3 but none is installed. You must install peer dependencies yourself.
npm WARN #covalent/core#1.0.0-beta.8-1 requires a peer of #angular/cdk#^2.0.0-beta.12 but none is installed. You must install peer dependencies yourself.
npm WARN #covalent/core#1.0.0-beta.8-1 requires a peer of #angular/material#^2.0.0-beta.12 but none is installed. You must install peer dependencies yourself.
This is my package.json
{
"name": "myAngularProject",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.0.0",
"#angular/cdk": "^5.0.0-rc0",
"#angular/common": "^5.0.0",
"#angular/compiler": "^5.0.0",
"#angular/core": "^5.0.0",
"#angular/forms": "^5.0.0",
"#angular/http": "^5.0.0",
"#angular/material": "^5.0.0-rc0",
"#angular/platform-browser": "^5.0.0",
"#angular/platform-browser-dynamic": "^5.0.0",
"#angular/router": "^5.0.0",
"#covalent/core": "^1.0.0-beta.8-1",
"#ng-dynamic-forms/core": "^1.4.34",
"#ng-dynamic-forms/ui-material": "^1.4.34",
"ag-grid": "^13.3.1",
"ag-grid-angular": "^13.3.0",
"angular-in-memory-web-api": "^0.3.2",
"core-js": "^2.5.1",
"ng2-dnd": "^4.2.0",
"rxjs": "^5.5.2",
"webpack": "^3.8.1",
"zone.js": "^0.8.18"
},
"devDependencies": {
"#angular/cli": "^1.5.0",
"#angular/compiler-cli": "^5.0.0",
"#types/jasmine": "2.5.38",
"#types/node": "^6.0.90",
"codelyzer": "~2.0.0",
"install-peers": "^1.0.2",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "^2.3.4"
},
}
My question is now, how do I add those peer dependencies manually and where? I've searched for ways to add them automatically but they do not work.
NOTE:
You don't have to add any peer dependencies, yourself. The message is only displaying that you have unmet dependencies, and I believe you can continue using #covalent package unless something breaks as these are warnings.
This seems to be an issue with the package #covalent as it depends upon #angular4 and it's respective packages and appears to be incompatible . Since there are few breaking changes from angular4 and angular5. So this is an expected behavior.
You have two options now precisely:
Submit PR to the said repository, so you can get a fix asap.
Wait for #covalent to release an update for #angular5, and once the update is out, you can safely update both #angular4 itself and #covalent as well.