[BUG] npm install --production creates/leaves behind empty directories of some devDependencies
Nobody has claimed this yet.
- 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
- 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"
}
}
- Execute the following command:
npm install --production - Note that npm has created (and/or not removed during execution) empty directories that correspond to some devDependencies. (See attached screenshot).

Environment
- OS: Windows 10
- Node: v16.13.0
- npm: 8.1.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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