npm error cannot read property 0 of undefined
I was trying to do an npm install and kept getting error saying something like “cannot read property 0 of undefined”.
After some googling where I get many instances of “me too” on forums and things like upgrading and downgrading versions of npm sometime works.
But I finally got it to work when I got the clue from the internet to…
- delete node_modules folder
- delete package-lock.json
- do “npm install” to recreate your node_modules folder
- then do npm install of whatever module you are trying to install.
Disclaimer: This worked for my case. It may or may not work for yours. Do at your own risk, especially when you are deleting your entire node_modules folder. Make sure that your package.json is good enough that you can restore back your node_modules folder from it.