Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] NPM v9 lose directory structure and pack/publish empty package #5853

Closed
2 tasks done
adenisovgit opened this issue Nov 14, 2022 · 6 comments · Fixed by #5927
Closed
2 tasks done

[BUG] NPM v9 lose directory structure and pack/publish empty package #5853

adenisovgit opened this issue Nov 14, 2022 · 6 comments · Fixed by #5927
Labels
Bug thing that needs fixing Priority 1 high priority issue regression:9.x Release 9.x work is associated with a specific npm 9 release

Comments

@adenisovgit
Copy link

adenisovgit commented Nov 14, 2022

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

when using npm >9 pack or publish produced empty package, just few headers

➜ pss-components git:(feature/PSS-390/componentsUpgrades) ✗ npm -v
9.1.1
➜ pss-components git:(feature/PSS-390/componentsUpgrades) ✗ npm pack
image

Expected Behavior

➜ pss-components git:(feature/PSS-390/componentsUpgrades) ✗ npm -v
8.19.3
➜ pss-components git:(feature/PSS-390/componentsUpgrades) ✗ npm pack
image

Steps To Reproduce

  1. In this environment...
  2. With this config...
  3. Run '...'
  4. See error...

Environment

  • npm: 9.1.1
  • Node.js: 16.15
  • OS Name: macOs 12.6
  • System Model Name:
  • npm config:
; copy and paste output from `npm config ls` here
@adenisovgit adenisovgit added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Nov 14, 2022
@adenisovgit adenisovgit changed the title [BUG] <title> [BUG] NPM v9 losing directory structure and pack/publish empty package Nov 14, 2022
@adenisovgit adenisovgit changed the title [BUG] NPM v9 losing directory structure and pack/publish empty package [BUG] NPM v9 lose directory structure and pack/publish empty package Nov 14, 2022
@wraithgar
Copy link
Member

There is not enough here to reproduce the issue. Notably the Steps To Reproduce entry has not been filled in.

@wraithgar
Copy link
Member

npm 9 changed how it parses its include/ignore lists. Please be sure to give a reproduction case that includes the contents of the package.json files, and any gitignore/npmignore files.

@nexdrew
Copy link

nexdrew commented Nov 23, 2022

Note that I had a package using this glob pattern in package.json:

  "files": [
    "lib/*"
  ]

Using npm 8, doing npm pack . would include any directories (and the modules within those directories) under lib.

Using npm 9, npm pack . would no longer include the directories (or their submodules) under lib.

Changing the glob pattern to this fixed the problem:

  "files": [
    "lib/**"
  ]

If helpful, I can create a repository to reproduce this.

@nexdrew
Copy link

nexdrew commented Nov 23, 2022

I suppose using this declaration would have been better in my case:

  "files": [
    "lib"
  ]

@wraithgar
Copy link
Member

~/D/n/s/glob $ npm pkg get files
"dir/*"
~/D/n/s/glob $ npx npm@8 publish --dry-run
npm notice 
npm notice 📦  files-example@1.0.0
npm notice === Tarball Contents === 
npm notice 0B   dir/sub/deepsub/file4.txt
npm notice 0B   dir/sub/file1.txt        
npm notice 0B   dir/sub2/file2.txt       
npm notice 286B package.json            
~/D/n/s/glob $ npx npm@9 publish --dry-run
npm notice
npm notice :package: files-example@1.0.0
npm notice === Tarball Contents ===
npm notice 286B package.json

@wraithgar wraithgar added regression:9.x Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Nov 23, 2022
@adenisovgit
Copy link
Author

I suppose using this declaration would have been better in my case:

  "files": [
    "lib"
  ]

That helps, thank you.

smaye81 added a commit to bufbuild/protobuf-es that referenced this issue Mar 8, 2023
npm v9 changed how it parses its include/ignore lists, see
npm/cli#5853 (comment).

Where it would previously include all files within the `dist` directory
with the following setting:

```json
  "files": [
    "dist/**/"
  ]
```

In v9.5.0, this pattern matches nothing.

This could lead to some packages being published empty (which occurred
in connect-es)

This PR updates the pattern to work with npm v9, verified by running
`npm pack` with and without the change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue regression:9.x Release 9.x work is associated with a specific npm 9 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants