Friday, October 21, 2022

[FIXED] How to clean (delete contents) folder with npm

Issue

I am trying to deploy a web project but before build it, I need to clear/delete the dist folder.

I could add a script that would run rm -rf dist/* but that would not work on Windows system.

Is there some npm package u other solution that allows deleting a folder with a command that works in every OS?


Solution

You can use rimraf: https://github.com/isaacs/rimraf.

Note that if you are using globs containing the globstar (**), you must double-quote them. Unix systems don't all support the globstar by default, but rimraf will expand them for you. Windows doesn't support single-quotes, so those can't be used. Remember that double-quotes must be escaped in JSON with a \.



Answered By - RyanZim
Answer Checked By - Gilberto Lyons (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.