---
# System prepended metadata

title: Cheatsheet JS

---

Cheatsheet JS
===

## Supprimer tous les répertoires node_modules d'un projet monorepo

`find . -name "node_modules" -exec rm -rf "{}" +`


## JS Error properties are not serializable

```
catch (error) {
 for (const property in error) {
    console.log(`${property}: ${error[property]}`)
}

const otherKeys = Object.keys(error)
console.error("other keyrs error", otherKeys)
```

With Object.keys or for-in loop, you can iterate over enumerable properties.


Unfortunately, the error has no useful non enumerable property, so you have to use the `getOwnPropertyNames` function.

```
const keys = Object.getOwnPropertyNames(error)
console.error("keys error", keys)
// return
keys error [ 'stack', 'message' ]
```

