Common npm troubleshooting tips


Throughout my learning experience with angular and npm installs, I have faced couple of installation and other issues. In this article, I have summarized those with the solutions as a reference. Hope it helps!

Issue 1
: Node. Js version keep showing as V0.10.2.2 after we install latest 8.x and above too.
Solution: Check the path variable set correctly to the install path of npm/ng.
If still problem exists, see if you have another installation exists already particularly it can be x-86 (32 bit os)version.
Try by running "Where node" command
If it exists, remove or delete the previous installation folder and try again. latest npm version will show up.
Issue 2: ng is not recognized as an internal or external command
Solution: Path environment variable has to be fixed to point specific to ng file .
C:\..\AppData\Roaming\npm
or try adding "run ng" prefix to npm commands as below.
Npm run ng <<command>

Issue3: Cannot resolve toPromise operator after upgrading to Angular CLI 7.
Solu​tion: Remove the below import line.No need to import.
import 'rxjs/add/operator/toPromise';

Issue 4: If cmd is not in the list of default integrated terminal in VS code.
Solution: Go to File-> Preference->Settings->User Setting-> Features-> Terminal
Edit the settings.json. Add an entry for cmd.exe for Intergrated>Shell>Windows section.
Reference link: https://stackoverflow.com/questions/40487445/how-to-change-the-integrated-terminal-in-visual-studio-code-or-vscode

Issue 5: Getting the below error with latest Angular CLI 7.x and angularfire2.
Failed to compile.
./node_modules/angularfire2/database/list/changes.js Module not found: Error: Can't resolve 'rxjs/Observable' in
Solution
With the latest angular CLI 7.x version, angular fire also has to be updated to the latest release @angular/fire.
Since all the fire modules are still referencing as from ../anglarfire/firedatabase, its throwing the above error.
Steps to fix
(i) Either downgrade the angular CLI to a compatible version for angularfire2 or install latest @angular/fire version(https://www.npmjs.com/package/@angular/fire).
(ii) E.g: import statements which are still referring to "import from ../angularfire2/firedabase" has to be change to latest version
"import from ../@angular/fire/firedatabase.
Commands to run
npm uninstall angularfire2 --save
npm install @angular/fire --save

Issue 6:
Getting the below error
Firebase Database persistent connection issue
Solution:
Go to "console.firebase.com".
Go to database configuration. Since it we are doing some testing and using test data which we are planning to delete soon.
For testdatbase, set the rules => read,write true which will solve the permission issue.

Comments