-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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] INIT_CWD missing in v7 #2033
Comments
Did a bit of research and found that the variable was set in a separate package called npm-lifecycle that has been removed from the npm CLI starting with version 7: INIT_CWD in npm-lifecycle. |
What would INIT_CWD contain that wouldn't be in |
Usually these are the same. The only case I know of is in the case of a postinstall script being run. There I was able to detect whether a script runs in postinstall without the I like that the console output for postinstall scripts is being hidden since version 7. Don't remember having seen anything useful there. |
Seems like this can be closed? |
What ?
|
I use INIT_CWD for building simple npm scripts to scaffold out new components. This is a breaking change and annoying enough that I'm going to revert versions until it's fixed. |
because of an issue with node 15 npm/cli#2033. In any case husky is not really helpful in CI
because of an issue with node 15 npm/cli#2033. In any case husky is not really helpful in CI
This was an oversight and is a bug in |
@isaacs : I don't see any test in the above commit, so this could regress in the future. |
@Geod24 The tests are in npm/config@7070885 This is a bug in @npmcli/config, not in the cli itself. |
This issue still appears on my machine. I'm using |
@KsRyY I've checked with |
I also repro this with 7.3.0. My script is literally |
I probably need to open an new issue. My problem, specifically, is about lifecycle script not being run (could be related to this problem though). When I installed |
It should be running them, but all success output is suppressed, so you’ll only see output if there’s a failure. |
Did a search on
INIT_CWD
, nothing relevant showed up. I also searched through the changelog and didn't find anything relevant.Current Behavior:
In order to get the directory the user was in when the command was run, one can use
process.env.INIT_CWD
, as documented here.This was introduced in v5.4.0 according to the changelog.
However, when upgrading from node 14 to node 15,
INIT_CWD
is not defined anymore. The upgrade hit me today, as I ranbrew upgrade
on my machine. I could reproduce on our Github CI.Expected Behavior:
I did not expect
INIT_CWD
to disappear, or if it does, I expect a way to access similar information.Steps To Reproduce:
I created a simple repository to see the regression: https://github.com/Geod24/npm-init-cwd-regression
The repository essentially consist of a
package.json
that doesnpm start
, andindex.js
is as follow:I setup a Github action to test on Ubuntu with Node 10, 12, 14, and 15.
One can see, when looking at the environment, that the one in 15 is quite different.
Environment:
Can reproduce on Mac and Ubuntu, and other details are linked above.
The text was updated successfully, but these errors were encountered: