# How to always rebuild without NPM cache

**URL:** <https://discuss.circleci.com/t/how-to-always-rebuild-without-npm-cache/1196>\
**Category:** Build Environment\
**Tags:** nodejs\
**Created:** [December 17, 2015, 9:34pm UTC](https://discuss.circleci.com/t/how-to-always-rebuild-without-npm-cache/1196 "2015-12-17T21:34:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbrock](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/tbrock/32/804_2.png) [@tbrock](https://discuss.circleci.com/u/tbrock)\
**Post date:** [December 17, 2015, 9:34pm UTC](https://discuss.circleci.com/t/how-to-always-rebuild-without-npm-cache/1196/1 "2015-12-17T21:34:05Z")

</div>

Packages and NodeJS versions move rapidly in the Javascipt world. We frequently fail builds and then pass them when rebuilding without the cache when we update packages or versions of Node.

Is there any way to always build without the cache?

I’m guessing you could specify empty cache\_directories in the circle.yml file and that might work but I thought it would be better to ask the pros.

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [February 9, 2016, 12:23am UTC](https://discuss.circleci.com/t/how-to-always-rebuild-without-npm-cache/1196/2 "2016-02-09T00:23:47Z")

</div>

Unfortunately there is no great way to do this right now other than just clearing out the node\_modules directory at the start of the build.

We have had many reports of general caching issues with node and are working on a better solution.

---

<div class="post-metadata">

**Author:** ![brandondoran](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/brandondoran/32/13250_2.png) [@brandondoran](https://discuss.circleci.com/u/brandondoran)\
**Post date:** [June 13, 2016, 9:15pm UTC](https://discuss.circleci.com/t/how-to-always-rebuild-without-npm-cache/1196/3 "2016-06-13T21:15:42Z")

</div>

Hi is there any update on this? Having to do a full npm install on every build is not good. That adds a good 3+ minutes for us. That’s a lot of overhead for something that 9 times out of 10 its not necessary.

---

<div class="post-metadata">

**Author:** ![luckycadow](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@luckycadow](https://discuss.circleci.com/u/luckycadow)\
**Post date:** [December 19, 2016, 2:59pm UTC](https://discuss.circleci.com/t/how-to-always-rebuild-without-npm-cache/1196/4 "2016-12-19T14:59:41Z")

</div>

Still no word on fixing the npm caching issues?

---

<div class="post-metadata">

**Author:** ![michelbitter](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@michelbitter](https://discuss.circleci.com/u/michelbitter)\
**Post date:** [January 6, 2017, 11:50am UTC](https://discuss.circleci.com/t/how-to-always-rebuild-without-npm-cache/1196/5 "2017-01-06T11:50:27Z")

</div>

@levlaz do you have any update about a possible fix?

---

<div class="post-metadata">

**Author:** ![renatoargh](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/renatoargh/32/14401_2.png) [@renatoargh](https://discuss.circleci.com/u/renatoargh)\
**Post date:** [January 24, 2017, 1:18pm UTC](https://discuss.circleci.com/t/how-to-always-rebuild-without-npm-cache/1196/6 "2017-01-24T13:18:11Z")

</div>

Hey guys, any updates on this? It would be great to be able to prevent npm cache with a simple setting on `circle.yml`. Looking forward for an answer.

---

<div class="post-metadata">

**Author:** ![djhrtmn](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/djhrtmn/32/15626_2.png) [@djhrtmn](https://discuss.circleci.com/u/djhrtmn)\
**Post date:** [March 9, 2017, 6:12pm UTC](https://discuss.circleci.com/t/how-to-always-rebuild-without-npm-cache/1196/7 "2017-03-09T18:12:21Z")

</div>

@levlaz

This is also causing intermittent failures for my team.

We updated our version of node to 6.9.5, which broke bindings for node-sass. Despite the fact that we have updated circle.yml to include the following, we still see errors where node-sass still has the bindings for the last version of node.

```auto
machine:
  node:
    version: 6.9.5
  post:
    - npm rebuild node-sass

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:37am UTC](https://discuss.circleci.com/t/how-to-always-rebuild-without-npm-cache/1196/8 "2018-06-18T11:37:49Z")

</div>


