Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

npm prune doesn't work inside of "scripts" #2827

Open
andrewrk opened this Issue · 2 comments

3 participants

Andrew Kelley Tim Oxley Rebecca Turner
Andrew Kelley
$ npm -v
1.1.59
$ node -v
v0.8.9
$ cat package.json 
{
  "name": "prune-test",
  "version": "0.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": { },
  "devDependencies": {},
  "scripts": {
    "doit": "npm prune"
  },
  "repository": "",
  "author": "",
  "license": "BSD"
}
$ ls node_modules/
async
$ npm prune
npm WARN package.json prune-test@0.0.0 No README.md file found!
$ ls node_modules/
$ npm install async
npm WARN package.json prune-test@0.0.0 No README.md file found!
npm http GET https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/async
async@0.1.22 node_modules/async
$ npm run doit
npm WARN package.json prune-test@0.0.0 No README.md file found!

> prune-test@0.0.0 doit /home/andy/tmp/prune-test
> npm prune

npm WARN package.json prune-test@0.0.0 No README.md file found!
$ ls node_modules/
async
Tim Oxley
Collaborator

Interesting! I can confirm this is still an issue with node 0.10.24 and npm 1.3.23 / current npm master 823010b.

Tim Oxley
Collaborator

Ok, so this has something to do with npm's depth config being different depending on whether you run it from the commandline or inside a script.

Adding a non-zero depth to the npm script command makes prune work correctly:

 "doit": "npm prune --depth Infinity" 

Add a script to compare the depth config setting:

"depth": "npm config get depth"

Running npm config get depth from the commandline depth will be Infinity while the npm run depth script will give a depth of 0.

It's possible this is by design, I vaguely recall bumping up against this depth thing before, perhaps @isaacs knows more?

Rebecca Turner iarna added the bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.