Skip to content
Abhishek Pratap edited this page Apr 16, 2021 · 1 revision

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.