How do I delete node_modules folder quickly? - node.js

When I want to delete a node_modules folder it takes ages when I delete it using Windows Explorer. How do I delete faster?

I use to have the same issue, taking hours to achieve the deletion until I found this workaround:
Select the node_modules folder. Do this with the file explorer.
Open Powershell as admin: press Alt+F, then S, then A.
Wait and accept to open Powershell as admin
Paste this command and press Enter: del /f/q/s *.* > nul.
WARNING
Please be sure to be in the folder node_modules. I mean, that the terminal path ends with ...\node_modules.
In the above command, we use the /f switch to force the deletion of read-only files. The /q switch enables quiet mode. The /s switch executes the command for all files in any folder inside the folder you’re trying to remove. Using *.* tells the del command to delete every file and > nul disables the console output improving performance and speed.
Wait for the process to take action.
Now go up one level in the directory with cd...
Finally use this command to delete the node_modules folder rmdir /q/s node_modules
In the above command, we use the /q switch to enable quiet mode, the /s switch to run the command on all the folders, and node_modules is the variable you need to specify to delete the folder you want.
If you get an error with Powershell try other terminals as administrator like Windows Terminal, Command Prompt (cmd) or third party terminals like ConEmu. I made this steps with Cmder and all the deletion was done in just 5 minutes. Off course this duration is variable according to the size of the folder.
References:
pureinfotech.com
ConEmu
Cmder

From you project folder use following command to delete it:
rd .\node_modules\ /s /q

Related

Open a file located in google file stream drive from command promt on windows

I'm currently running the scrip located on Google Drive file stream from the Spyder IDE with no problem, but looking for a run from anaconda promt. When I try:
cd G:\My Drive\LBTC API\V0.2
It doesn't do anything at all, I got the same result if I try:
cd G:\
Thanks
The cd command (or chdir) changes the current directory of the given drive, but does not change the current drive:
rem /* This changes the current directory of drive `G:` to `\My Drive\LBTC API\V0.2`,
rem but if you are on another drive, say `C:`, you will not notice a change: */
cd "G:\My Drive\LBTC API\V0.2"
rem // When you change to the drive `G:` you will see the effect of the `cd` command:
G:
To change the drive as well as you must specify the /D option:
rem // This changes to the drive `G:` and changes its current directory:
cd /D "G:\My Drive\LBTC API\V0.2"
Actually the quotation marks around the path is not needed for the cd command, but I tend to use them also here as they do not harm, and they are needed for paths in many other situations.
First you change to the virtual drive and then you change the directory:
$ G:
$ cd /My Drive/LBTC API/V0.2
That should work fine, hope it helps

my npm is broken - Cannot read property 'get' of undefined

I have visual studio 2017 and wanted to make a Cordova app. I have had many problems with it now and have found a problem. Right now I run windows 10 and have installed nodejs but npm does not work. I have tested with different command but I always get the same mistake. I have canceled Node but I can not drive.
Just posting this here to help any future wanderers,
In my case the actual issue was due to the presence of a space in my windows user name folder. Which was also clear by looking at the first line of the stack trace,
Error: EPERM: operation not permitted, mkdir 'C:\Users\FirstName'
Since there is no directory present named FirstName and the actual directory was supposed to be FirstName LastName its trying to run mkdir, for which its getting operation not permitted.
Following is how i fixed it thanks to citoreek, g8up & gijswijs
run npm config edit to edit your config, this will open up a text file in notepad or your configured editor,
then change cache path from
; cache=C:\Users\Gijs van Dam\AppData\Roaming\npm-cache
to
cache=C:\Users\GIJSVA~1\AppData\Roaming\npm-cache
Remember to remove the ; at the start,
next question would be how do we know to replace our user name with GIJSVA~1?
There are a couple of ways to target this,
Go to C:\Users open power Shell and execute following command
cmd /c dir /x
what this does is, list down all the directories in current directory along with their short names which aren't supposed to contain any spaces and normally are 6 characters or less in length. Copy that short name against your user name directory and use this in your cache path.
You will notice these short names only exist for directories either containing spaces or which are longer than 6 characters. (for the rest of the directories their short names should be same as their directory name)
If you don't want to use above command, then simply remove all the spaces from your user name in your cache path, then take the first 6 characters of the user directory name and postfix it with ~1. You should also uppercase it, but it appears not to be making any difference.
After you are done with editing this file, save your changes then try again after closing any active power shell / bash process and reopening them.
I apologize for my question. I just needed to reboot the windows.
In my case this was a permissions problem with the ~/.np* files and directories. These were owned by root by mistake. I did
sudo find "~/.np*" -exec chown myuser {} \;
and that solved it.
base path is specified in the file
.npmrc

cd Desktop gives an error no such file/ directory in terminal

In Terminal, on mac, when i use the cd Desktop to view files through the terminal i get an error "no such file or directory"
When i checked the current working directory, it shows I'm in /home/
I do not understand why suddenly it doesn't work.
I tried using a .profile file to have some alias and path change. Could this change in .profile file cause this error?
Try use cd (with no parameters) for jump to your home directory which should be /Users/username. Then use cd Desktop. Alternatively you can do "cd ~/Desktop"
First of all, make a desktop folder in the home folder, then open the command prompt
Also, try the " cd desktop " command you will not get an error. Always remember the case-sensitive words before running Command.

How do I change the directory in Git Bash with Git for Windows?

How would I change to the directory C:/Users/myname/project name in Git Bash?
cd /c/users/myname/project\ name
Beware that ls /, or typing cd / followed by Tab-completion, might not show the existence of this folder, but cd /c will still work. Also note that pwd (to print the current working directory) might show something like /bin, but this might not be the actual working folder for commands such as git clone, which might use the folder from which Git Bash was started.
If the you know how many levels up from your current working directory, you could use cd ../project/name to avoid writing the entire directory path.
The .. represents moving 1 directory up.
You will need to use quotes in your directory name, or the short version of the filename.
You can find the short version of the file name by issuing the command:
dir /x
If I remember correctly. I do not have a windows machine.
It is a version of bash shell though, so you should be able to simply quote it. (And the dir /x may or may not work.)
If you are at the a directory and wanna switch to sub directory use :
cd "project name"
If you wanna go to a different path use the whole path :
cd "C:/Users/myname/project name"
But you can avoid use white spaces in project files and folders and instead use underscore
An alternative that worked for me (Windows 10 x64) is putting the full address in quotes:
cd "D:\BWayne\Documents\- School\Developer\-- Backend\Test for GitBash"
I could then do like mkdir, touch, etc and it successfully put them in the Test for GitBash folder.

how to recursively delete directory starting with "xxxxx"?

I need to delete Directories that are starting with particular String "user"and i need to delete all the sub-folders in the Directory too.
I used removedirectory which deletes directory only when it is empty.
Normally I would open a command window then cd to the directory you want to delete,
Enter the command: "del /S /F *.* *" to delete all files and subdirectories.
Backup to the parent directory: cd ..
Remove the directory: rmdir "user*"
Use "del/?" to see all the options for del.
If you have to do this in c++, you can use the "system()" call.
BTW: I did not test this just now, so no guarantee.

Resources