npm init brings in flattened dependencies in v3 #8716

Closed
substack opened this Issue Jun 27, 2015 · 4 comments

Projects

None yet

4 participants

@substack
Contributor

I usually do npm init right before I publish, so I've already got a ton of files in node_modules/ with the new flatter behavior in v3. When it comes time to npm init, npm thinks all of those flattened dependencies belong in my package.json as top-level dependencies.

@iarna iarna added the bug label Jun 27, 2015
@iarna iarna added this to the 3.x milestone Jun 27, 2015
@iarna
Member
iarna commented Jun 27, 2015

Yup, it should totally do the right thing here.

To do this it needs to use read-package-tree like everything else in npm@3 and then look for packages with a _requiredBy containing #USER, which indicates they were installed by direct user action and not due to a subdep or an existing package.json. It might be reasonable to also include any module that doesn't have a _requiredBy field– that'd be modules installed via npm@2, and any module with a _requiredBy containing /, which would be from a previous package.json.

@govpack
govpack commented Jun 29, 2015

I heard it always does the "right thing".
based both on universal standards & models for ethical and absolute correctness.
I mean, they exist don't they!! RTFM or RTFSC it's all in there. init'ing after the fact, i like that, that's so manga, now they're busy re-wiring who put what where!! 😱

@iarna iarna modified the milestone: 3.x-next-next, 3.x Jul 20, 2015
@iarna
Member
iarna commented Jul 30, 2015

Aaand, this lives off in init-package-json, which complicates matters because it's building its tree in an entirely npm independent manner. I think this is going to require some (much needed) refactoring to extract those parts of the new installer into independent modules.

@iarna iarna modified the milestone: 3.x-next-next, 3.x-next Jul 30, 2015
@iarna iarna modified the milestone: 3.x-next-next, 3.x-next Aug 10, 2015
@iarna iarna added a commit that referenced this issue Aug 13, 2015
@iarna iarna init-package-json@1.8.0
Fixes #8716
1fd5c1f
@iarna iarna self-assigned this Aug 13, 2015
@iarna iarna added the in progress label Aug 13, 2015
@iarna iarna modified the milestone: 3.x-next-next, 3.x-next Aug 13, 2015
@iarna iarna added a commit that referenced this issue Aug 13, 2015
@iarna iarna init-package-json@1.8.0
Fixes #8716
PR-URL: #9269
b3ba768
@zkat zkat added a commit that referenced this issue Aug 14, 2015
@zkat @iarna zkat + iarna init-package-json@1.8.0
Fixes #8716
PR-URL: #9269
c163287
@zkat zkat added a commit that closed this issue Aug 14, 2015
@zkat @iarna zkat + iarna init-package-json@1.8.0
Fixes #8716
PR-URL: #9269
139dd92
@zkat zkat closed this in 139dd92 Aug 14, 2015
@othiym23 othiym23 removed the in progress label Aug 14, 2015
@iarna iarna modified the milestone: 3.3.0, 3.x-next-next Aug 14, 2015
@iarna
Member
iarna commented Aug 14, 2015

So yeah, this landed in 2.14.0 and 3.3.0!

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