-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[BUG] Organization packages installed from the registry are failing to execute the lifecycle scripts #5380
Comments
This works on npm 6.14.2. It looks like this issue started in npm 7 & persists in npm 8. |
To test this idea, I installed https://www.npmjs.com/package/npm-lifecycle-hooks! & it ran the lifecycle methods! Then I copied the package contents to a new folder & published it as a scoped package in the GitLab NPM Registry & then it did not run any lifecycle methods! |
Can confirm this behavior too - lifecycle scripts are not running when installing from a custom registry. If a |
Found the issue with our registry (JFrog) is not sending This is the relevant code: cli/workspaces/arborist/lib/node.js Line 317 in b397774
Here's the documentation for npm's registry api: https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md Check with your registry provider if there are discrepancies. @un-focused what is the response GitLab is sending you for the
|
Just weighing in here: The patch has stalled because in order for gitlab to support This could be greatly simplified if npm publish included this metadata as part of the Is there a reason the publish PUT request does not include all the metadata required by npm install? Assuming such a change to NPM, Gitlab would still need to be patched for PACKAGE_JSON_ALLOWED_FIELDS to add |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Scoped packages (own organization) installed from a registry (GitLab) do not execute the postinstall scripts or any lifecycle scripts. I have tested this behaviour in npm 7 & npm 8 & am aware that npm 8 suppress the output from scripts so I used the following command to test my theory:
Other packages execute their postinstall but my package does not run. If I use a local path to the tar file, it does run, but setting the version does not.
If I download the tar manually from the registry & set the path to it, it will run the scripts!
Expected Behavior
Scoped packages installed from a registry exhibit the same behaviour as if I were using a local path to tar file. They should execute the lifecycle scripts.
Steps To Reproduce
None of my scripts are working after publishing an npm package. I will try to give a simple example here to demonstrate the point.
The package.json scripts object (relevant parts) looks like this:
The scripts/postinstall looks like this:
This works when I execute:
inside the package that I am publishing.
When I install it locally it works too:
After the pack, in another project, I specify the path to the tar file generated & everything works!
If I run:
& then install it inside the same project that consumes the node_module, it does not execute the install or postinstall script.
To debug this, I run the command:
and have tried npm i --foreground-scripts --loglevel verbose as well to better understand the problem.
The documentation for the npm lifecycle is lacking & I could not find any information online. Please note that this package is publish in a private gitlab registry and I am able to download & "install" the package as I see it in my node_modules but it does run the lifecycle scripts when installing remotely from npm.
I do have an .npmrc file specified.
Environment
The text was updated successfully, but these errors were encountered: