diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md index 490daf991588..fa10747dacc4 100644 --- a/doc/languages-frameworks/javascript.section.md +++ b/doc/languages-frameworks/javascript.section.md @@ -196,7 +196,7 @@ buildNpmPackage rec { * `makeCacheWritable`: Whether to make the cache writable prior to installing dependencies. Don't set this unless npm tries to write to the cache directory, as it can slow down the build. * `npmBuildScript`: The script to run to build the project. Defaults to `"build"`. * `npmFlags`: Flags to pass to all npm commands. -* `npmInstallFlags`: Flags to pass to `npm ci`. +* `npmInstallFlags`: Flags to pass to `npm ci` and `npm prune`. * `npmBuildFlags`: Flags to pass to `npm run ${npmBuildScript}`. * `npmPackFlags`: Flags to pass to `npm pack`. diff --git a/pkgs/build-support/node/build-npm-package/default.nix b/pkgs/build-support/node/build-npm-package/default.nix index 1038bb2abcb4..5ab86996e56b 100644 --- a/pkgs/build-support/node/build-npm-package/default.nix +++ b/pkgs/build-support/node/build-npm-package/default.nix @@ -17,7 +17,7 @@ , npmBuildScript ? "build" # Flags to pass to all npm commands. , npmFlags ? [ ] - # Flags to pass to `npm ci`. + # Flags to pass to `npm ci` and `npm prune`. , npmInstallFlags ? [ ] # Flags to pass to `npm rebuild`. , npmRebuildFlags ? [ ] diff --git a/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh b/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh index 4a222de26bbf..c3983e289568 100644 --- a/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh +++ b/pkgs/build-support/node/build-npm-package/hooks/npm-install-hook.sh @@ -27,7 +27,7 @@ npmInstallHook() { local -r nodeModulesPath="$packageOut/node_modules" if [ ! -d "$nodeModulesPath" ]; then - npm prune --omit dev + npm prune --omit dev $npmInstallFlags "${npmInstallFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}" find node_modules -maxdepth 1 -type d -empty -delete cp -r node_modules "$nodeModulesPath"