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] process.env.npm_config_user_agent missing in v7 #1834

Closed
rafgraph opened this issue Sep 20, 2020 · 11 comments
Closed

[BUG] process.env.npm_config_user_agent missing in v7 #1834

rafgraph opened this issue Sep 20, 2020 · 11 comments
Assignees
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@rafgraph
Copy link

rafgraph commented Sep 20, 2020

Current Behavior:

npm i --save-dev husky doesn't run the install and postinstall scripts after installing the package so the git hooks are never setup. No error is thrown. I haven't checked to see if this is unique to the husky package or not.

Expected Behavior:

For the install and postinstall scripts to run after the package is installed and the git hooks to be set up.

Steps To Reproduce:

npm i --save-dev husky
Then check to see if the git hooks have been added to .git/hooks/pre-commit (compare this to installing using npm v6)

Environment:

  • OS: MacOS 10.15.6
  • Node: 12.18.3
  • npm: v7.0.0-beta.11
@rafgraph rafgraph added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Sep 20, 2020
@rafgraph rafgraph changed the title [BUG] postinstall not run [BUG] install, postinstall are NOT run after the package is installed Sep 20, 2020
@darcyclarke darcyclarke added beta and removed Needs Triage needs review for next steps labels Sep 25, 2020
@nlf
Copy link
Contributor

nlf commented Oct 1, 2020

So there's a few things happening here:

  1. We no longer display the output of install scripts unless an error occurs, this is deliberate and intended to reduce the amount of text we print during an install process.

  2. The script actually is running, and failing, the problem is that it is not setting the process.exitCode to a non-0 value when an error occurs, so npm does not print the error. The error in question is

husky > Setting up git hooks
Cannot destructure property 'name' of 'which_pm_runs_1.default(...)' as it is undefined.
husky > Failed to install
  1. The current version of husky (4.x) relies on the package which-pm-runs which relies on process.env.npm_config_user_agent being populated, which was removed from the environment variables that npm 7 provides. This is something that we will consider re-adding to help reduce friction.

@darcyclarke darcyclarke added this to the OSS - Sprint 16 milestone Oct 1, 2020
@rafgraph
Copy link
Author

rafgraph commented Oct 2, 2020

Thanks for the detailed explanation. I don't work on husky so can't say what their thoughts are on this.

@rafgraph rafgraph changed the title [BUG] install, postinstall are NOT run after the package is installed [BUG] process.env.npm_config_user_agent missing in v7 Oct 3, 2020
@nlf
Copy link
Contributor

nlf commented Oct 9, 2020

we published v7.0.0-rc.4 today that resolves this

@nlf nlf closed this as completed Oct 9, 2020
@rafgraph
Copy link
Author

rafgraph commented Oct 11, 2020

Thanks @nlf, however I'm still getting the same result with husky, the hooks aren't setup when running install. Maybe there is another suppressed error? I tried npm i --save-dev husky --loglevel silly but nothing unusual shows up, is there another command that I can use to see all the output like v6?

@rafgraph
Copy link
Author

@nlf still having an issue with installing husky on v7.0.3. Should I open a new issue? Thanks.

@ssamakar
Copy link

Same here with v7.4.2.

@nlf
Copy link
Contributor

nlf commented Jan 21, 2021

if the issue is that the npm_config_user_agent environment variable isn't set, then we should reopen this issue. if you're having another problem entirely, then yes please do open a new issue.

@alexander-mai
Copy link

I have the problem that npm_config_user_agent is not defined on Version 7.7.2. When I switch back to 7.6.x the value is set.

@jspivack
Copy link

@nlf @alexander-mai getting the same bug in 7.7.4

@nlf
Copy link
Contributor

nlf commented Mar 24, 2021

Can one of you please open a new issue for this? We'll take a look ASAP

@alexander-mai
Copy link

I opened a new Issue: #2960.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

6 participants