/Tips-For-Developers

This is a compilation of odd tips and tricks that I have stumbled across to make developers life a little easy. Feel free to add such tips and tricks.

Useful tips here 👇 to make developers happy 😄

To search and delete node_modules from older projects.🚮

we all suddenly face problem with device space getting full, main culprit for us developers is dependencies (node_modules), it can be more than 300MB+ 😲 for react and more if you add more dependencies later on, which we all do 🤦‍♂️.

There is a awesome tool to kill them, i mean not really kill but delete.

npkill is just awesome easy to use cli tool.

  • You can install globally by running

$ npm i -g npkill

Make sure you have node installed

  • You can also use it without installing it by running

$ npx npkill

npkill searching npkill deleting

Some Useful commands

  • Search node_modules directories in your projects directory
  • $ npkill -d ~/projects

  • Displays the magenta color cursor... because I like magenta!
  • $ npkill --color magenta

  • List directories called "dist" and and show errors if any occur:
  • $ npkill --target dist -e

  • List vendor directories in your projects directory, sort by size, and show that in gb:
  • $ npkill -d '~/more projects' -gb --sort size --target vendor


    To fix long import relative paths for project.🖇

    We all have file path looked like this ../../../../../ so on. At some point it feels like we are importing something out of project, if you have not been there than you are lucky or have great folder structure and if you have one contact me 😉.

    There is an easy solution for VS Code users, sorry for the 1% people who are not using VS Code. 😆

    Steps to be followed :

    • create jsconfg.json file in your project root directory.
    • Inside file map paths in your project using keyword.
      {
        "compilerOptions": {
          "baseUrl": "./",
          "paths": {
            @components/*": ["components/*"]
            @lib/*": ["lib/*"]
            @styles/*": ["styles/*"]
          }
        }
      }
      

      🎉 Done 🎊 yes its that simple, and for to use this in your file just replace the ../../../../../SomeComponent with @components/SomeComponent.