Sometimes I removes my dist
folder to make sure I will not run old code. I noticed that nx
caches build results. This means that nx
does nothing when nothing has changed, meaning my dist
directory remains empty after a build.
What I remove the cache
$> npm cache clean --force && rimraf ./node_modules/.cache/nx
I think that nx reset
might works too instead, but this works as well!
However, when I run my build job again it still uses cache:
> nx run build [remote cache]
> NX Successfully ran target build for project docker (939ms)
Nx read the output from the cache instead of running the command for 1 out of 1 tasks.
The only way I can make sure it rebuild is
$> nx run build --skip-nx-cache
But I'm not sure how to do this with npm
though
$> npm build -- --skip-nx-cache
doesn't work, because it will add the --skip-nx-cache
to all underlying commands.
Anyway, the main problem in my case is [remote cache]
. I don't know anything about remote cache. How does this work? and most of all, how can I disable this?
You can try setting an environment variable:
NX_SKIP_NX_CACHE=true nx run build