···161161162162`buildNpmPackage` allows you to package npm-based projects in Nixpkgs without the use of an auto-generated dependencies file (as used in [node2nix](#javascript-node2nix)). It works by utilizing npm's cache functionality -- creating a reproducible cache that contains the dependencies of a project, and pointing npm to it.
163163164164+Here's an example:
165165+164166```nix
165167{ lib, buildNpmPackage, fetchFromGitHub }:
166168···190192 };
191193}
192194```
195195+196196+In the default `installPhase` set by `buildNpmPackage`, it uses `npm pack --json --dry-run` to decide what files to install in `$out/lib/node_modules/$name/`, where `$name` is the `name` string defined in the package's `package.json`. Additionally, the `bin` and `man` keys in the source's `package.json` are used to decide what binaries and manpages are supposed to be installed. If these are not defined, `npm pack` may miss some files, and no binaries will be produced.
193197194198#### Arguments {#javascript-buildNpmPackage-arguments}
195199···204208* `npmBuildFlags`: Flags to pass to `npm run ${npmBuildScript}`.
205209* `npmPackFlags`: Flags to pass to `npm pack`.
206210* `npmPruneFlags`: Flags to pass to `npm prune`. Defaults to the value of `npmInstallFlags`.
211211+* `makeWrapperArgs`: Flags to pass to `makeWrapper`, added to executable calling the generated `.js` with `node` as an interpreter. These scripts are defined in `package.json`.
207212208213#### prefetch-npm-deps {#javascript-buildNpmPackage-prefetch-npm-deps}
209214210210-`prefetch-npm-deps` can calculate the hash of the dependencies of an npm project ahead of time.
215215+`prefetch-npm-deps` is a Nixpkgs package that calculates the hash of the dependencies of an npm project ahead of time.
211216212217```console
213218$ ls
···216221...
217222sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
218223```
224224+225225+#### fetchNpmDeps {#javascript-buildNpmPackage-fetchNpmDeps}
226226+227227+`fetchNpmDeps` is a Nix function that requires the following mandatory arguments:
228228+229229+- `src`: A directory / tarball with `package-lock.json` file
230230+- `hash`: The output hash of the node dependencies defined in `package-lock.json`.
231231+232232+It returns a derivation with all `package-lock.json` dependencies downloaded into `$out/`, usable as an npm cache.
219233220234### corepack {#javascript-corepack}
221235