I am using ts-node-dev
and I need to change its cache directory (defaults to the operating system's temporary directory).
I have two commands defined in a package.json
file, a start
and a start-custom-cache
like so:
"scripts": {
"start-custom-cache": "ts-node-dev --transpile-only --cache-directory $npm_config_myflag_cache_dir ./src/parser.ts",
"start": "ts-node-dev --transpile-only ./src/parser.ts",
...
}
I can launch start
from a bash script like this:
npm start --prefix parser -- -f "$FILEPATH" -c "$CONFIGPATH" -o "$NORMALIZED" -g "$GRAPH_DIR" --csv
This works correctly and those variables get passed as arguments correctly.
The problem is that I am defining a desirable cache directory (rather than the default operating system temporary directory) and want to pass it to ts-node-dev
.
According to this source there is the environment variable TS_NODE_CACHE_DIRECTORY
I can set to change it.
Checking the npm package information here, it should apparently match a flag --cache-directory
.
I've tried running the following but it still writes to /tmp/
:
export TS_NODE_CACHE_DIRECTORY="$NPM_CACHE_DIR"
npm start --prefix parser -- -f "$FILEPATH" -c "$CONFIGPATH" -o "$NORMALIZED" -g "$GRAPH_DIR" --csv
There appears to be a --cache-directory
parameter to be passed.
I've tried passing it like this but it didn't work:
npm run start --prefix parser -- -f "$FILEPATH" -c "$CONFIGPATH" -o "$NORMALIZED" -g "$GRAPH_DIR" --csv --cache-directory "$NPM_CACHE_DIR"
Based on this source I also tried this (with the equals sign):
npm run start --prefix parser -- -f "$FILEPATH" -c "$CONFIGPATH" -o "$NORMALIZED" -g "$GRAPH_DIR" --csv --cache-directory="$NPM_CACHE_DIR"
Lastly, following suggestions from this source, I also tried using the start-custom-cache
variant like so:
npm run start-custom-cache --prefix parser --myflag_cache_dir="$NPM_CACHE_DIR" -- -f "$FILEPATH" -c "$CONFIGPATH" -o "$NORMALIZED" -g "$GRAPH_DIR" --csv
Unfortunately, nothing works.
Thanks for reading, would be amazing if someone could chime in.