"npm prefix" doesn't report where 'package.json' is


(Igor Pellegrini) #1

What I Wanted to Do

Know the current npm prefix

What Happened Instead

Instead of the

closest parent directory to contain a package.json
(from npm-prefix docs)

I get returned the closest parent directory to contain “node_modules”.

Reproduction Steps

mkdir test
cd test/
npm init
npm install jquery
mkdir vendor
cp -r node_modules/ vendor/
npm prefix        # returns "~/test"
cd vendor/
npm prefix        # returns "~/test/vendor"

Details

  • I just assume that it reports the ‘node-modules’ directory, based on the returned output; the actual behaviour could be another one
  • atm I can’t use major NPM/Node versions, and test again there, because of some dependencies

Platform Info

$ npm --versions
{ npm: '3.10.10',
  ares: '1.10.1-DEV',
  http_parser: '2.8.0',
  icu: '52.1',
  modules: '48',
  napi: '3',
  node: '6.14.4',
  openssl: '1.0.2j-fips',
  uv: '1.16.1',
  v8: '5.1.281.111',
  zlib: '1.2.8' }
$ node -p process.platform
linux

(Lars Willighagen) #2

It looks like it’s been that way since forever, so I suppose this is a documentation error, and re-categorized it accordingly.

Edit: keep forgetting the docs are in the repo too, here’s a PR:

https://github.com/npm/cli/pull/116


(system) closed #3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.