I have a Nx monorepo project which has a node_modules/.bin
folder with content like this:
drwxr-xr-x 84 demo staff 2688 Dec 8 13:29 .
drwxr-xr-x 997 demo staff 31904 Dec 8 13:29 ..
lrwxr-xr-x 1 demo staff 20 Dec 8 13:29 JSONStream -> ../JSONStream/bin.js
lrwxr-xr-x 1 demo staff 18 Dec 8 13:29 acorn -> ../acorn/bin/acorn
lrwxr-xr-x 1 demo staff 29 Dec 8 13:29 ag -> ../@asyncapi/generator/cli.js
This folder is also configured to be cached.
After running a build, when looking at the corresponding cached content in .nx/cache/.../outputs/node_modules/.bin
, the symbolic links are gone:
-rwxr-xr-x 1 demo staff 251 Aug 25 11:27 JSONStream
-rwxr-xr-x 1 demo staff 60 Aug 25 11:26 acorn
-rwxr-xr-x 1 demo staff 7780 Aug 25 11:26 ag
When a process is running ag
after the cache is restored, an error occurs:
REDACTED/node_modules/.bin/ag [..additional parameters..]
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module './package.json'
Require stack:
- /REDACTED/node_modules/.bin/ag
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/REDACTED/node_modules/.bin/ag:8:21)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/REDACTED/node_modules/.bin/ag'
]
}
When restoring the symbolic link everything works as expected.
I would expect, that the Nx caching mechanism is preserving the symbolic links. Is it expected to do so?