You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
npm changed the way npm publish command works. From npm v8.5.0 my previous release setup broke (final version it works - 8.4.1).
When np does command npm publish <np contents folder> (for instance npm publish ./dist) it will pack original package.json, readme.md and /dist folder will be packed too, but it will not be flatten as it was before. npm publish doc:
All files are included by default, with the following exceptions:
Certain files that are relevant to package installation and distribution are always included. For example, package.json, README.md, LICENSE, and so on.
If there is a "files" list in package.json, then only the files specified will be included. (If directories are specified, then they will be walked recursively and their contents included, subject to the same ignore rules.)
If there is a .gitignore or .npmignore file, then ignored files in that and all child directories will be excluded from the package. If both files exist, then the .gitignore is ignored, and only the .npmignore is used.
If the file matches certain patterns, then it will never be included, unless explicitly added to the "files" list in package.json, or un-ignored with a ! rule in a .npmignore or .gitignore file.
At the end we got in .tgz:
/package
- package.json - original
- readme.md - original
/dist/
- package.json - modified by np
.... other dist files
1. Your build script should put future package content to /dist
2. Run np npm exec np or run right away command npm publish ./dist which will be build and run by np at the end
To test without trying to publish you can also run npm pack
Expected behavior
I expect that my package would contain files that specified in "contents" and "files" props of package.json (as it was before npm 8.5).
Also it should not contain original package.json from source, but modified by np clean package.json.
It is not bug of npm because behavior matches with their docs for 8.x =)
Additional Notes
If you run npm publish from /dist folder it will do it correctly - /dist would become the root of the package and it will contain single package.json fixed by np. So it looks like np (since npm v8.5) should do "cd /dist" before running publish command.
Environment
np - 7.6.2
Node.js - v16.13.2
npm - 8.15.0 (problem appeared at v8.5.0)
Git - 2.37.1.windows.1
OS - win 10 / also tested on MacOs
The text was updated successfully, but these errors were encountered:
Description
npm changed the way
npm publish
command works. From npm v8.5.0 my previous release setup broke (final version it works - 8.4.1).When np does command
npm publish <np contents folder>
(for instancenpm publish ./dist
) it will pack original package.json, readme.md and /dist folder will be packed too, but it will not be flatten as it was before.npm publish doc:
At the end we got in .tgz:
Steps to reproduce
0. Setup
package.json
.npmignore
1. Your build script should put future package content to /dist
2. Run np
npm exec np
or run right away commandnpm publish ./dist
which will be build and run by np at the endTo test without trying to publish you can also run
npm pack
Expected behavior
I expect that my package would contain files that specified in "contents" and "files" props of package.json (as it was before npm 8.5).
Also it should not contain original package.json from source, but modified by np clean package.json.
It is not bug of npm because behavior matches with their docs for 8.x =)
Additional Notes
If you run
npm publish
from/dist
folder it will do it correctly - /dist would become the root of the package and it will contain single package.json fixed by np. So it looks like np (since npm v8.5) should do "cd /dist" before running publish command.Environment
np - 7.6.2
Node.js - v16.13.2
npm - 8.15.0 (problem appeared at v8.5.0)
Git - 2.37.1.windows.1
OS - win 10 / also tested on MacOs
The text was updated successfully, but these errors were encountered: