npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.49k stars 3.17k forks source link

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

Closed func0der closed 2 months ago

func0der commented 3 months ago

Is there an existing issue for this?

This issue exists in the latest npm version

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

milaninfy commented 2 months ago

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 commented 2 months ago

@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 commented 2 months ago

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