Skip to content

[BUG] INIT_CWD missing in v7 #2033

Description

@Geod24

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 ran brew 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 does npm start, and index.js is as follow:

const process = require('process');
console.info(process.env);

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 7.xwork is associated with a specific npm 7 release

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions