Skip to content

rimraf specification doesn't work in windows #8

@cpu999

Description

@cpu999

The current "clean" script makes use of "rimraf" to delete the directory contents of "dist/*" like this:

"clean": "rimraf dist/*",

However, in windows when you add a trace of the error this reports you get to see this:

> npm run clean -s

 { [Error: ENOENT, no such file or directory 'C:\usr\local\angular\projects\npm-scripts-example-master\dist\*']
  errno: 34,
  code: 'ENOENT',
  path: 'C:\\usr\\local\\angular\\projects\\npm-scripts-example-master\\dist\\*',
  syscall: 'unlink' }

The reason is that contrary to Unix, windows does not expand "dist/*" into a list of files but passes it "as is".

Since most users would have Git installed, and on the PATH, and it has a windows version of "bash", I found that this fixes the issue.

"clean": "bash -c \"rimraf dist/*\"",

Another way to fix it is to remove the "/*".

"clean": "rimraf dist",

This last one also removes the "dist" directory but more importantly, the file "dist/.gitkeep" which was not removed (as no files starting with a dot are picked up by the * wildcard) does get removed now. If that was intended, good then this last specification works, otherwise the one with "bash" might be better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions