If you work with javascript frameworks, it’s hard to get by these days without using npm. Package management and resolving dependencies is hard, and npm does make it easy.

npm though does not always work as expected and when it does not, you start to question why so many people rely on it.

Last night, I wanted to add a new component to the react native project I am working on.…

A new component which was just one file, what could wrong? A lot of things went wrong. After I ran the command

npm install –save react-native-keyboard-spacer

the results told me it had installed four packages and removed 345 packages. Uh! What! That does not sound right. I refreshed the emulator, and my fear did come true. That one command had uninstalled all dependencies which did not meet the install criteria. 😣

The next five hours were spent fixing dependencies issues and errors. Nativebase a component I relied on was set to “native-base”: “^2.2.0” in package.json, which meant that it had installed the latest version following the npm install command. Thanks to GitHub, the solution was to remove ^ and run “npm update”. React-navigation was set to ^1.0.0-beta.11, which meant that it had updated to the latest version, breaking my apps navigation.

Days like these, I wish we relied less on package management solutions and were still downloading individual files/folders to make it part of the project.

P.S: Remember to commit your code often.

Sunil Shenoy @sunil
Made with