npm / npm/cli

[BUG] npm install --production creates/leaves behind empty directories of some devDependencies

Open
#3,975 4 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 2 Release 8.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
Current Behavior

When using the command npm install --production npm creates (and/or fails to remove during execution) empty directories for some devDependencies.

Expected Behavior

When using the command npm --production I expect npm to install only the packages listed in dependencies, omit the packages listed in devDependencies and not create/leave behind empty directories for any devDependency packages.

Steps To Reproduce
  1. Create a new directory with the following package.json:
{
  "name": "npm-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "dayjs": "^1.10.7"
  },
  "devDependencies": {
    "webpack-cli": "^4.9.1"
  }
}
  1. Execute the following command: npm install --production
  2. Note that npm has created (and/or not removed during execution) empty directories that correspond to some devDependencies. (See attached screenshot).

npm-bug-01

Environment
  • OS: Windows 10
  • Node: v16.13.0
  • npm: 8.1.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior on Windows 10 with the provided package.json and npm install --production command. Inspect which empty devDependency directories remain after installation; done means only dependencies are installed and no empty directories for webpack-cli or other devDependencies remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.