nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1# shellcheck shell=bash
2
3npmBuildHook() {
4 echo "Executing npmBuildHook"
5
6 runHook preBuild
7
8 if [ -z "${npmBuildScript-}" ]; then
9 echo
10 echo "ERROR: no build script was specified"
11 echo 'Hint: set `npmBuildScript`, override `buildPhase`, or set `dontNpmBuild = true`.'
12 echo
13
14 exit 1
15 fi
16
17 if ! npm run ${npmWorkspace+--workspace=$npmWorkspace} "$npmBuildScript" $npmBuildFlags "${npmBuildFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}"; then
18 echo
19 echo 'ERROR: `npm build` failed'
20 echo
21 echo "Here are a few things you can try, depending on the error:"
22 echo "1. Make sure your build script ($npmBuildScript) exists"
23 echo ' If there is none, set `dontNpmBuild = true`.'
24 echo '2. If the error being thrown is something similar to "error:0308010C:digital envelope routines::unsupported", add `NODE_OPTIONS = "--openssl-legacy-provider"` to your derivation'
25 echo " See https://github.com/webpack/webpack/issues/14532 for more information."
26 echo
27
28 exit 1
29 fi
30
31 runHook postBuild
32
33 echo "Finished npmBuildHook"
34}
35
36if [ -z "${dontNpmBuild-}" ] && [ -z "${buildPhase-}" ]; then
37 buildPhase=npmBuildHook
38fi