---
title: "Discussion on \"Node.js: refreshing a module using require.cache\" | Hashnode"
description: "Discussion on \"Node.js: refreshing a module using require.cache\". This is purely in reference to CommonJS modules.\n\nTLDR\nBefore I bore you with why I did this, refreshing a module can be done by deleting its reference in the require.cache object. Like so:\nrequire('./some-module')\n\n// use module\n\ndelete require.cach..."
url: "https://hashnode.com/posts/nodejs-refreshing-a-module-using-requirecache/6739b4167e35daafe18ccf4b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Node.js: refreshing a module using require.cache](https://gemmablack.dev/nodejs-refreshing-a-module-using-requirecache?utm_source=hashnode&utm_medium=feed)

This is purely in reference to CommonJS modules. TLDR Before I bore you with why I did this, refreshing a module can be done by deleting its reference in the require.cache object. Like so: require('./some-module') // use module delete require.cach...

Nov 17, 2024 · 5 min read · gemmablack.dev  
Read the article

-   [#requirecache](https://hashnode.com/tag/requirecache)
-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#cache-invalidation](https://hashnode.com/tag/cache-invalidation)
-   [#cache](https://hashnode.com/tag/cache)
-   [#hmr](https://hashnode.com/tag/hmr)
-   [#commonjs](https://hashnode.com/tag/commonjs)

## Written by

[Gemma Black](https://hashnode.com/@GemmaBlack)

@GemmaBlack · London, UK

  
[View profile](https://hashnode.com/@GemmaBlack)

I'm a Senior Software Engineer. With 10+ years working within tech teams, and 20+ years working with code, I develop across the stack, assisting with application design, maintenance, deployment and DevOps within the AWS Cloud.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
