有时我会删除我的
dist
文件夹以确保我不会运行旧代码。我注意到 nx
缓存构建结果。这意味着当没有任何更改时 nx
不执行任何操作,这意味着我的 dist
目录在构建后仍为空。
我删除缓存的内容
$> npm cache clean --force && rimraf ./node_modules/.cache/nx
我认为
nx reset
也可能有效,但这也有效!
但是,当我再次运行构建作业时,它仍然使用缓存:
> 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.
我确保它重建的唯一方法是
$> nx run build --skip-nx-cache
但我不知道如何用
npm
来做到这一点
$> npm build -- --skip-nx-cache
不起作用,因为它会将
--skip-nx-cache
添加到所有底层命令中。
无论如何,我的主要问题是
[remote cache]
。我对远程缓存一无所知。这是如何运作的?最重要的是,我如何禁用它?
您可以尝试设置环境变量:
NX_SKIP_NX_CACHE=true nx run build