Skip to content
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] No lifecycle hooks are run at all #7730

Closed
2 tasks done
func0der opened this issue Aug 17, 2024 · 3 comments
Closed
2 tasks done

[BUG] No lifecycle hooks are run at all #7730

func0der opened this issue Aug 17, 2024 · 3 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@func0der
Copy link

func0der commented Aug 17, 2024

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

No livecycle hooks (https://docs.npmjs.com/cli/v10/using-npm/scripts#life-cycle-operation-order) are run at all.

Expected Behavior

Livecycle hooks are run

Steps To Reproduce

  1. Create package.json

    {
      "name": "failing",
      "version": "1.0.0",
      "main": "index.js",
      "scripts": {
        "preinstall": "echo pre",
        "postinstall": "echo post",
      },
      "author": "",
      "license": "ISC",
      "description": ""
    }
    
  2. Run 'npm install license-checker --foreground-scripts --verbose'

  3. See nothing. No postinstall or preinstall or any hooks are executed.

Actually all hooks seem to not be working. Tested it with the version hooks, too.

Environment

  • npm: 10.8.2
  • Node.js: v22.6.0
  • OS Name: Fedora 40
  • System Model Name: -
  • npm config:
; node bin location = /home/user/.nvm/versions/node/v22.6.0/bin/node
; node version = v22.6.0
; npm local prefix = /home/user/Projects
; npm version = 10.8.2
; cwd = /home/user/Projects
; HOME = /home/user
; Run `npm config ls -l` to show all defaults.
@func0der func0der added Bug thing that needs fixing Needs Triage needs review for next steps labels Aug 17, 2024
@milaninfy
Copy link
Contributor

for this package.json version hook runs fine.

{
  "name": "rep",
  "version": "1.0.3",
  "main": "index.js",
  "scripts": {
    "version": "echo \"testing version hook\""
  },
  "author": "",
  "license": "ISC",
  "keywords": [],
  "description": ""
}
~/workarea/rep $ npm version patch

> version
> echo "testing version hook"

testing version hook
v1.0.3
~/workarea/rep $ npm -v
10.8.2

@milaninfy
Copy link
Contributor

@func0der when you install a pacakge then scripts mentioned inside that pacakge's package.json file will execute, in your case it should run the scripts of license-checker when you install that package, but I believe that you are expecting that npm install license-checker will run the script of failing which it will not execute, as mentioned in my previous comment the version script is working fine. If you still think there is something I missed, please provide your test setup, complete re-production steps, logs etc.

@milaninfy
Copy link
Contributor

Closing. If this is still a problem please feel free to reopen this issue, or create a new issue w/ steps to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

2 participants