I've been updating the version of an angular version, I used the angular update guide, and used ng update #angular/core#11 #anuglar/cli#11, for the most part I was able to get it all done but when I try and do ng server, I get this error Picture of terminal error
Here is my Package.json
Packag.json
I have tried deleteing node modules and packag-lock and doing npm install, but I still get the same error when doing ng serve.
I know that my #angular/material isn't the same version as the rest of my angular, when I update my material version it just causes more and more errors.
Your node modules are probably still cached. Try the following command
npm cache clean --force
then do npm install again
Related
I am using the following book to build a MERN stack CRUD application. I'm having trouble installing and running graphql.
https://www.amazon.com/Pro-MERN-Stack-Development-Express-dp-1484243900/dp/1484243900/ref=mt_paperback?_encoding=UTF8&me=&qid= (published in 2019).
When I try to start the server contained in this repo https://github.com/vasansr/pro-mern-stack-2/tree/05.02-graphql-schema-file with the command npm start the app crashes and it returns an
Error: Cannot find module 'graphql/validation/rules/PossibleTypeExtensions'
I then followed some advice from a previous instance of this question on here to npm install karma-sinon-chai for the dependancies. But then I get the following error:
npm WARN apollo-graphql#0.4.4 requires a peer of graphql#^14.2.1 but none is installed. You must install peer dependencies yourself.
For me simply running npm install -g graphql fixed the problem (I had already installed Apollo globally with npm install -g apollo).
As per the error message apollo-graphql required a module from the graphql library validation/rules/PossibleTypeExtentions. The version of graphql I was using, as found by looking in my package.json, was "graphql":"^0.13.2".
I first tried to change this by changing my package.json to "^14.3.1". But after trying to install and run graphql I got the same error messages and when I looked in my package.json it had reverted back to "^0.13.2".
This may have been caused by my package.lock, locking me into that version. I then deleted package.lock, and node_modules folder.
I then ran the command nom install --save graphql#14.3.1, this worked fine.
I then just had to reinstall babel and Apollo-server-express and after this everything worked fine.
Each time I use angular/cli to create a new project by launching the following command
ng new Project-Name
I get the following error
npm ERR! Unexpected end of JSON input while parsing near '...-4","#angular/common"'
I tried to force clean the cache and re-try but still face the same problem.
NodeJS version: 12.16.3
npm version: 6.14.4
Angular CLI version: 9.1.4
OS: Windows 10 Home win32 x64
Edit: All the commands above I run them in Powershell as administrator
This is not a definitive answer but it looks like your global packages are corrupted in some way.
This bug may be caused by many different things. I suggest doing the following.
Install Node Version Manager (or NVM for Windows) and install Node version 10.16.1. This is enough for angular 9 and from my experience it is the most stable version for development. This should also change your NPM version so that may also help.
Uninstall global angular package npm uninstall -g #angular/cli
Force clear cache npm cache clean --force
Just to double check npm cache verify
You can also try clearing your %temp% and %roaming% AppData/npm-cache
install latest angular package npm install -g #angular/cli#<your-version>
if this error still occurs, consider using another shell
If this don't solve the problem try to manually locate the package.json file that is throwing an error and investigate.
In my Angular project, I was having errors while trying to build a docker image. I used ng update #angular/cli #angular/core and was able to resolve that error, and now I'm able to create a docker container of my project that is served.
However, now I cannot serve my project with ng serve because I get the following error:
An unhandled exception occurred: compiler.getInfrastructureLogger is not a function
getInfrastructureLogger is NOT a function I created, I'm assuming it's coming from a node mod. I've tried deleting the node_mod folder and install them again with npm install, but I still get the same error. I've tried cleaning my npm cache and I still get the error.
I went back a couple of commits (to before I ran ng update #angular/cli #angular/core) and then I'm able to run ng serve with no errors, but am then unable to create my docker images. I need to be able to use containers, so I have to use ng update #angular/cli #angular/core. But I also want to be able to serve my project as a standalone (plus it better for developing).
Does anyone have any advise on this error? Where it's coming from? Solutions?
I would really appreciate it. Thanks for any help you can give.
***To specify, I used ng update #angular/cli #angular/core --force it was the only for me to run that command.
My project is Angular 8, node node version 12.14.
The update in angular versions or one of the dependencies caused this error. We could help more if we knew what version of Angular you were coming from and what version you were updating to.
First, if you're upgrading to the latest stable Angular version (8.x), make sure you have node 10.9 or later installed.
Regardless, the Angular Upgrade Guide is an awesome tool that allows you to input the version you're coming from and the version you're going to and it will give you step-by-step instructions as to what you need to do in order to upgrade your angular app. Try upgrading one major version at a time following these instructions. It almost always resolves my problems.
Please note: It's better to upgrade one version at a time
I have been struggling for days to try and get angular to update. I have finally narrowed it down to the fact when I run
ng new
it creates an angular app using version 1.7.4 but I have updated angular to version 8.1.2. when I run
ng --version
I get the message "your global version is 8.1.2 is greater than your local version 1.7.4 the local version will be uses"
I have run npm
npm update -g#angular/cli
npm update #angular/cli
but nothing. I have also deleted the files in
c:\users\user\appdata\roaming\npm\node_modules\#angular
and tried running
npm install #angular/cli
Has anyone got any idea either how to update my local install of angular or when I run
ng new
to get it to use the global version?
Thanks
npm update will update your package to the latest safe version, i.e. it won't increase a major version of your current package which is 1 in your case. A change of a major version means there will be breaking changes.
So you need to explicitly specify the package version to which you want to migrate. I.e. npm update #angular/cli#^8.1.2 or npm install #angular/cli#^8.1.2, sorry I mostly use yarn so not sure which of these 2 commands will work.
when i run the following command, it shows 6.4.1.
npm run ng --version
but when i am running the following command, it is installing 8.1.0 and getting error. i do not understand how it is happening.
npm install -g #angular/cli
i tried the following commands. but it is not working
npm cache clean --force
npm install -g #angular/cli
Error Screen
My Requirement:
Angular 6
how can i resolve this?
You should the latest (12+) node when upgrading to angular 8. You can download it from here.
After upgrading node, the issues should go away.
For simple use cases and thanks to the work done in Angular 8, you can upgrade to the latest release using one command:
$ ng update #angular/cli #angular/core
After running this command, the lazy loaded routes will be automatically migrated to the new import syntax which is standard compliant and brings Angular close to the open web platform.
You also need to be aware of the following issues when upgrading your project:
Angular 8 makes use of the latest TypeScript 3.4, so even if the upgrade process completes with success you might have some syntax errors that may be due to the better type inference system used by the latest version which detects new potential typing issues but in the end this will improve your code quality and helps you avoid bugs in the future. You can see the new features of TypeScript 3.4 from the official docs.
You need to have Node.js 12+. Simply run node -v to verify your Node version. You can install the latest version from the official website