N: getting extraneous errors when `npm ls -g`

Created on 2 Jun 2017  ·  8Comments  ·  Source: tj/n

Description

Latest OSX Sierra 10.12.5
n -V output: 2.1.7
Installed via n-install

I have these versions installed

    node/6.10.3
  ο node/7.9.0
    node/8.0.0

I run npm ls --depth=0 -g

and I get

/Users/<username>/.n/lib
└── [email protected]

npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/call-limit
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/detect-indent
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/lazy-property
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/pacote
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/update-notifier
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/node-gyp/node_modules/path-array
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-color
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/request/node_modules/bl
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/request/node_modules/node-uuid
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/request/node_modules/performance-now
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/request/node_modules/safe-buffer
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/request/node_modules/har-validator/node_modules/ajv
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/request/node_modules/har-validator/node_modules/har-schema
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/assert-plus
npm ERR! extraneous: [email protected] /Users/<username>/.n/lib/node_modules/npm/node_modules/sorted-union-stream/node_modules/stream-iterate/node_modules/stream-shift

Most helpful comment

I was having the same issue and narrowed down some reproduce steps. I think the extraneous messages related to npm/node_modules are because n is simply overwriting with each install and not removing older files. When the npm dependencies change between versions, the left-over files from previous npm installations cause the error messages from some commands.

Reproduce steps with default locations on OS X.:

n 8.7.0
rm -rf /usr/local/lib/node_modules/npm/node_modules
n 6.11.4
npm list --global --depth=0  # clean
n 8.7.0
npm list --global --depth=0  # extraneous

All 8 comments

Your npm install is at /Users//.n/lib

I would recommend using npm install -g n to install n. The n-install doesn't default the install dir to /usr/local/lib like the npm install. I would check that and see if that fixes your problem.

So on Mac, what base install of node/npm would you recommend in order to install n since I think by default it doesn't exist. It's kind of a weird catch22 right? I need node/npm to install n, a node version manager, to install different versions of node/npm ;)

Install it with https://nodejs.org/en/. That'll give you npm as well, and then you can install the node version manager n with npm i -g n

have the same issue and installed with npm i -g n:

/usr/local/lib
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/fie/node_modules/[email protected]@abbrev
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/fie/node_modules/[email protected]@address
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/fie/node_modules/[email protected]@agent-base

@troy0820 @goldenyz Same here, I just uninstalled my whole n/avn setup and installed LTS node from official site (which btw, always requires sudo since it's installed as root) and I installed n and avn as recommended, and I still get similar output:

$ sudo npm ls --depth=0 -g
Password:
/usr/local/lib
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/call-limit
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/detect-indent
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/lazy-property
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/libnpx
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/pacote
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/worker-farm
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/node-gyp/node_modules/path-array
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-color
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/request/node_modules/bl
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/request/node_modules/node-uuid
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/request/node_modules/performance-now
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/request/node_modules/har-validator/node_modules/ajv
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/request/node_modules/har-validator/node_modules/har-schema
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/jsprim/node_modules/assert-plus
npm ERR! extraneous: [email protected] /usr/local/lib/node_modules/npm/node_modules/sorted-union-stream/node_modules/stream-iterate/node_modules/stream-shift
npm ERR! invalid: [email protected] /usr/local/lib/node_modules/npm/node_modules/strip-ansi/node_modules/ansi-regex

Extraneous packages _even though the error is there_ doesn't impact N from being functional. This is because some of these packages are either invalid or not in your parent's package.json.

You can read about it here npm docs

I was having the same issue and narrowed down some reproduce steps. I think the extraneous messages related to npm/node_modules are because n is simply overwriting with each install and not removing older files. When the npm dependencies change between versions, the left-over files from previous npm installations cause the error messages from some commands.

Reproduce steps with default locations on OS X.:

n 8.7.0
rm -rf /usr/local/lib/node_modules/npm/node_modules
n 6.11.4
npm list --global --depth=0  # clean
n 8.7.0
npm list --global --depth=0  # extraneous

Issue closed from merging PR #470.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tekumara picture tekumara  ·  3Comments

qw3rtman picture qw3rtman  ·  6Comments

Olgagr picture Olgagr  ·  4Comments

tommilimmot picture tommilimmot  ·  3Comments

soyxsandeep picture soyxsandeep  ·  3Comments