npm ERR! Unexpected token < in JSON
Have you ever gotten that error while working on your code? Seems weird right? how does that even happen? You have just installed some modules using npm, write some code, pushed it on for a code review from your peers. Then everyone checks your code and gives it the green light to merge into master. It goes into master, and every one pull from master. All of a sudden every one’s project can not serve on localhost because of this error,
npm ERR! Unexpected token < in JSONSo you and your fellow engineers are scratching your heads wondering what this means. One of you tries to go into the package.json to find the < token because the error says so. No luck. Your package.json looks pristine. No errors to be found.
What do you do now? Worry not my friends. There are a couple of things you can try.
Open up terminal if you are not on it already and go into your project’s root folder where your package-lock.jon is at and
- run this command:
rm -f package-lock.json && npm install2. if that doesn’t work, try
rm -rf node_modules && npm installand if doing one of those doesn’t work, you can try doing:
rm -f package-lock.json && rm -rf node_modules && npm installand if all else fails, Google is your best friend!

