Open milahu opened 3 years ago
package.json
{ "name": "npmlock2nix-bug-patchshebangs", "version": "1.0.0", "scripts": { "install": "cross-env echo hello" }, "dependencies": { "cross-env": "*" } }
error
sh: /build/node_modules/.bin/cross-env: /usr/bin/env: bad interpreter: No such file or directory
/build/node_modules/.bin/cross-env is a symlink to /build/node_modules/cross-env/src/bin/cross-env.js
/build/node_modules/.bin/cross-env
/build/node_modules/cross-env/src/bin/cross-env.js
the source file cross-env/src/bin/cross-env.js is NOT patched by patchShebangs (find "$@" -type f -perm -0100) because it is not executable (file mode 0644)
find "$@" -type f -perm -0100
in the preinstall hook, add
preinstall
# patchShebangs will patch only executable files cat package.json | jq -r '. | select(.bin != null) | .bin | values[]' \ | while read binTarget; do chmod +x "$binTarget"; done
maybe avoid jq and use nix to extract a list of binTargets no, this concerns dependencies, where we dont have the json files parsed into nix
jq
package.json
error
/build/node_modules/.bin/cross-env
is a symlink to/build/node_modules/cross-env/src/bin/cross-env.js
the source file cross-env/src/bin/cross-env.js is NOT patched by patchShebangs (
find "$@" -type f -perm -0100
) because it is not executable (file mode 0644)solutions
in the
preinstall
hook, addmaybe avoidno, this concerns dependencies, where we dont have the json files parsed into nixjq
and use nix to extract a list of binTargets