-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[DOCS] npm pack
doesn't include file specified in main
field
#7799
Comments
It does include main file when files array is empty ~/workarea/rep/test2 $ cat package.json
{
"name": "test2",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"files":[],
"author": "",
"license": "ISC",
"description": ""
}
~/workarea/rep/test2 $ npm pack
npm notice
npm notice 📦 [email protected]
npm notice Tarball Contents
npm notice 21B index.js
npm notice 214B package.json
npm notice Tarball Details
npm notice name: test2
npm notice version: 1.0.0
npm notice filename: test2-1.0.0.tgz
npm notice package size: 289 B
npm notice unpacked size: 235 B
npm notice shasum: eb360f5112d60fbe8bd07966ba034e1b646d3677
npm notice integrity: sha512-dPPp1JvlntDq+[...]FQDURsukkbOzw==
npm notice total files: 2
npm notice
test2-1.0.0.tgz |
Can you show the output of |
~/workarea/rep/test2 $ cat package.json
{
"name": "test2",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"files":["some-random-file.js"],
"author": "",
"license": "ISC",
"description": ""
}
~/workarea/rep/test2 $ npm pack --dry-run
npm notice
npm notice 📦 [email protected]
npm notice Tarball Contents
npm notice 21B index.js
npm notice 235B package.json
npm notice Tarball Details
npm notice name: test2
npm notice version: 1.0.0
npm notice filename: test2-1.0.0.tgz
npm notice package size: 301 B
npm notice unpacked size: 256 B
npm notice shasum: fea7a90b35ad5b89f5e454561162acc6c55ea122
npm notice integrity: sha512-Fwa3c+JPwwxy9[...]W/iiFfl/UFzkA==
npm notice total files: 2
npm notice
test2-1.0.0.tgz
|
Looks like index.js is included in both cases. |
I did some further testing and figured out that the issue only comes up, when the For example, given the following package: / ❯ rg "" .
./pkg1/package.json
1:{
2: "name": "pkg1",
3: "version": "1.0.0",
4: "main": "./example.js",
5: "files": []
6:}
./pkg1/example.js
1:module.exports = { x: 42 }; It works when imported: / ❯ mkdir pkg2; cd pkg2
/pkg2 ❯ npm install ../pkg1
added 1 package in 110ms
/pkg2 ❯ node -e "console.log(require('pkg1'))"
{ x: 42 } But doesn't include the file in the archive: /pkg2 ❯ cd ../pkg1
/pkg1 ❯ npm pack --dry-run
npm notice
npm notice 📦 [email protected]
npm notice === Tarball Contents ===
npm notice 84B package.json
npm notice === Tarball Details ===
npm notice name: pkg1
npm notice version: 1.0.0
npm notice filename: pkg1-1.0.0.tgz
npm notice package size: 165 B
npm notice unpacked size: 84 B
npm notice shasum: b76b9256d8f14870061f7b9a1d3ef7c7def7099e
npm notice integrity: sha512-iDd4jjnyTHmxu[...]q4z81tFDwGOaQ==
npm notice total files: 1
npm notice
pkg1-1.0.0.tgz |
Is there an existing issue for this?
This is a CLI Docs Problem, not another kind of Docs Problem.
Description of Problem
The following section of the docs suggest that even with an empty
files
array, the path frommain
inpackage.json
would still be included when runningnpm pack
, but it doesn't behave accordingly for me:cli/docs/lib/content/configuring-npm/package-json.md
Lines 296 to 302 in 6ca609e
Potential Solution
If someone can confirm that this is indeed a discrepancy between the docs and the implementation, one should be adjusted to match the other.
Affected URL
No response
The text was updated successfully, but these errors were encountered: