When I try to clean a folder with npm by running npm run clean
(code underneath), I get the following error:
rm: cannot remove 'lib/*': No such file or directory
In my package.json, I'm using the following scripts:
{
"scripts": {
"clean": "rm -r lib/*",
"show": "ls lib/*"
}
}
I'm absolutely sure the folder exists. I've tried using single quotes around the lib
path. I know glob expansion is working: the npm run show
works perfectly fine.
I do not want to add any dependencies like rimraf as suggested here. I also do not care about windows support. I know I could use rm -r lib && mkdir lib
which does work. I'm mostly interested in why rm -r lib/*
gives the error. Could someone help me out?
npm version: 5.5.1
node version: 8.9.3
Are you sure your lib folder is not already empty?
rm -r somedir/*
Gives this error when ran on an empty dir because "*" doesn't exist because the dir is empty.
If you want to remove the lib folder itself you have to type rm -r lib
Use rimraf: Run the unix command rm -rf in Node.js
npm i rimraf -D
and in your script, write
"scripts": {
"delete:folder": "rimraf lib/*",
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With