-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hook scripts are removed from npm v7 #110
Comments
Mhm, that is a bummer. I'll have to think about the alternatives for this. There was always the path of pre-populating a cache directory that NPM would then pick sources from. We could also patch sources before we pass them to npm. The problem with the latter approach is with scripts that requires custom binaries during execution. It also makes it harder to patch files that are being generated on the fly... |
i have implemented how is this useful? such a small script is better hackable than a full-feature package manager in #npm install --offline --nodedir=${nodeSource nodejs}
export NODE_preInstallLinks='${builtins.toJSON preInstallLinks}'
node --trace-uncaught --trace-warnings ${npm-install-mini-js} where |
How about something like this
I want to use |
not all packages have a package.json. this non-standard was introduced by yarn |
The problem with this remains the same: we occasionally have to patch scripts while npm does it's thing as a dependant package might execute a script to e.g. compile native binaries before it finishes.
On 26 September 2021 14:05:16 CEST, ilkecan ***@***.***> wrote:
How about something like this
```
SCRIPT="$(readlink -f ./node_modules/.hooks/preinstall)"
package_dirs="$(find ./node_modules -type f -name "package.json" | xargs --no-run-if-empty dirname)"
while read package_dir; do
export npm_package_name="$(echo "$package_dir" | awk -F'/' '{ if ($(NF - 1) ~ /^@/) printf "%s/%s\n", $(NF -1), $NF; else print $NF }')"
pushd $package_dir
$SCRIPT
popd
done <<< "$package_dirs"
```
I want to use `--ignore-scripts` which also seems to disable hook scripts so I needed a way to manually patch the scripts. I tried this and it seems to be doing the job. Obviously it could be polished.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#110 (comment)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
I think we could perform
before the current
without any side effects, apart from the patched scripts. To give some context, I was actually trying to package an electron project and I was unable to build the native add-ons for the electron run-time during EDIT: It seems the embedded code snippets don't work across repositories, so
|
I just tried something like your proposal on newer npm and I was greeted with:
This obviously doesn't work with a build sandbox.... Fuck NPM. If a lockfile suddenly doesn't have enough information anymore the implementation sucks. |
I am sorry, but I am not sure how the error you are getting is related to our discussion.
What I understand from this is, you are trying to package a project using npmv7 that has a lockfile created with npmv6. But I think that shouldn't be a use case this project supports. The packager should use the same npm version the upstream uses. Can you try migrating the lockfile to v7 before using |
yepp. the lockfile is just a collection of name, version, url, hash
while were at it: fuck npm's flat node_modules. every sane system uses symlinks for deduplication ps: more experimental stuff at https://github.com/milahu/nodejs-hide-symlinks |
to defend NPM: this could be a rare edge-case, where npm7 actually installs more packages than npm6: the command we want is npm ci (clean install) which will use only the lockfile to resolve deps, or fail. |
Yeah, so far we didn't have to care much about that. Perhaps that will be a requirement going forward. I'll try to upgrade one of our examples to npmv7 and test your recommendation with that again... |
This project currently uses hook scripts (specifically "preinstall" hook) to patch the shebangs. But as far as I can tell, hook scripts are removed from npm v7[1][2]. Do you have any plans to change the way shebangs are patched in a way that could also work with npm v7?
[1] npm/cli#2692
[2] npm/cli#3486
Opened as the continuation of #108 (comment) to make the discussion more visible since that PR is closed.
The text was updated successfully, but these errors were encountered: