In this StackOverflow question I answered what to do when you get an unexpected token '\u0000' error when using npm install -g to install some package.
I'm a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts, I will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.
As you may know, I'm really into Ionic framework lately and am helping out on StackOverflow with the knowledge I gained so far with the framework. I'm currently #3 in the top All time answerers list.
This is probably a Windows specific issue but I haven't found any information when googling this issue. I had been using ionic framework which relies on Cordova (or Phonegap). However, the problem is not specific to any of these packages. I see this error quite often. So, the error is when I run a command such as the following:
npm install -g cordova
However, I could substitute various other packages and get the same error. I'll paste the snippet (very brief) below of the error message. What is strange is that I had an ionic project working in that directory earlier. Then today it told me that ionic could not be found. My hunch is that this is a different issue than the main issue I am describing here.
I installed git bash so I do have a linux-like environment that I could try. I would just select Git Bash for a bash window with various bash commands. If there is an easier way to fix this for Windows users, please let me know. I have seen courses on Pluralsight where the instructors seem to be happily using npm with no problems. Also, when I use yeoman, I also at some point, in many cases, get the same error.
The error is
Thanks in advance for any help/advice, Bruce
My answer was:
Via this question on SO it could be that you just have to do:npm cache clean
But, also try the other methods suggested there like adding the registry option:npm install <packagename> --registry http://registry.npmjs.org/.
Or, if you've been mingling with the
package.jsonfile by yourself, check if it's valid.
— Nikola Brežnjak (@HitmanHR) February 9, 2016