[BUG] In monorepositories `npm publish` and `npm pack` take into account `.gitignore` and ignore `.npmignore`
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
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
In monorepositories (with workspaces in package.json), npm publish and npm pack take into account .gitignore and ignore .npmignore.
Expected Behavior
If .npmignore is present, npm publish and npm pack should take that file into account and ignore .gitignore.
Steps To Reproduce
git clone git@github.com:KostyaTretyak/npm-bug-with-monorepo.git
cd npm-bug-with-monorepo
npm i
cd packages/pkg1
npm pack
Now you can see that the packages/pkg1/pkg1-1.0.0.tgz archive does not contain a dist directory.
Environment
- npm: 10.1 (and tested with v9.6.7);
- Node.js: v18.17.1;
- OS Name: Ubuntu 22.04;
- System Model Name: HP Notebook
- npm config:
; "user" config from /home/me/.npmrc
//registry.npmjs.org/:_authToken = (protected)
; node bin location = /home/me/.nvm/versions/node/v18.17.1/bin/node
; node version = v18.17.1
; npm local prefix = /srv/git/npm-bug-with-monorepo
; npm version = 10.1.0
; cwd = /srv/git/npm-bug-with-monorepo
; HOME = /home/me
; Run `npm config ls -l` to show all defaults.
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
Clone KostyaTretyak/npm-bug-with-monorepo, run npm i, then npm pack from packages/pkg1 to reproduce the archive contents. Read the workspace package.json, .npmignore, and .gitignore handling around npm pack and publish; done means a present .npmignore is honored and the dist directory is included in the generated archive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100