npm3 confused about misplaced node_modules/package.json #9285

timoxley opened this Issue Aug 15, 2015 · 10 comments


None yet

5 participants


Accidentally ended up with a package.json in node_modules.

npm v3.3.0 doesn't take it well:

npm-packagejson-node_modules@1.0.0 /Users/timoxley/Projects/tests/npm-packagejson-node_modules
├── UNMET DEPENDENCY inherits@^2.0.1
└──  extraneous error: ENOTDIR: not a directory, open '/Users/timoxley/Projects/tests/npm-packagejson-node_modules/node_modules/package.json/package.json

Problem is the ENOTDIR: not a directory, open.

Works fine in npm v2.

To reproduce, use npm v3 to npm ls in

git clone
cd npm-packagejson-node_modules
npm ls
@othiym23 othiym23 added the bug label Aug 17, 2015
@othiym23 othiym23 added this to the 3.x milestone Aug 17, 2015
iarna commented Aug 17, 2015

Ok, so what you're reporting is that:

If a non-directory is placed in the node_modules folder then npm ls will report that this is the case in npm@3 where it didn't in npm@2.

Additionally, it does this in rather fraught terms "omg extraneous, augh error!!".

I would propose that we should be reporting this. Eg, if I run npm ls I want to know what's in my node_modules folder... But maybe at a warning level (or just a note) and with a more useful message like "plain file found in node_modules folder".

iarna commented Aug 18, 2015

Backchannel talk w/ @othiym23: He'd like the message suppressed entirely unless the user explicitly asks for it.

@iarna iarna modified the milestone: 3.x-next-next, 3.x Aug 18, 2015
iarna commented Aug 18, 2015

Ok, so what we're gonna do is suppress error entries that have ENOTDIR registered as their only error. This will allow random file cruft in your node_modules while still reporting, say, parse errors in your linked deps package.json files.


@iarna sounds good to me 👍

@iarna iarna modified the milestone: 3.x-next, 3.x-next-next Aug 21, 2015
@iarna iarna modified the milestone: 3.x-next-next, 3.x-next Sep 11, 2015
iarna commented Sep 11, 2015

I underestimated how painful writing the tests tests for #9537 would be, combined with the short week, so this has to be pushed out.

@iarna iarna self-assigned this Sep 14, 2015
@iarna iarna added the in progress label Sep 14, 2015
iarna commented Sep 17, 2015

Thank you for this, we shipped the fix for this in npm@3.3.4

@iarna iarna closed this Sep 17, 2015
@iarna iarna removed the in progress label Sep 17, 2015

Hi @iarna

This issue seems to persist on V 3.3.8 even after re-installing the node version afresh after purging

npm ERR! error in /usr/local/lib/node_modules/npm-debug.log: ENOTDIR, open '/usr/local/lib/node_modules/npm-debug.log/package.json'
npm ERR! invalid: bplist-parser@0.1.0 /usr/local/lib/node_modules/appium/node_modules/bplist-parser```

@calshankar I've seen this too, so I'm going to reopen this until we figure out whether this is the same issue, or an instance of a new issue.

@othiym23 othiym23 reopened this Oct 21, 2015
@othiym23 othiym23 modified the milestone: 3.x, 3.3.4, next-next-3 Oct 21, 2015
iarna commented Oct 26, 2015

ok, this only happens with globals, which is why existing tests didn't find it

@iarna iarna modified the milestone: next-next-3, next-3 Oct 27, 2015
@iarna iarna modified the milestone: next-next-3, next-3 Nov 10, 2015
@iarna iarna removed their assignment Apr 25, 2016

Any update on this one? I see this also happening e.g entry.node.spec.ts/package.json I'm using 3.10.9

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