-
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
[BUG] npm publish
complains on bin
field examples from npm docs
#7302
Comments
Related: npm/package-json#83 |
@mrazauskas As we are trying to create the executable files in the bin folder , the executable files should be in bin folder and path should be the directory to the bin folder . if we keep it out of bin and publish it , It will give us the same warning as it is a required to put the files in bin and same path should be given in package.json file. do below steps and it should work as expected.
|
Thanks for comment. It works, of course. I just try to explain that |
@Santoshraj2 Hm.. I was speaking about the two examples just under the one you have fixed. Also not sure if these examples is the problem. As far as I can understand |
@mrazauskas Yes you are right ./path/to/program and path/to/program are same. so other examples looks fine to me. |
@Santoshraj2 Exactly! The examples look right to me too, but |
The examples which you are talking about is just representing two ways of mentioning executable files. when you have one you can say bin : "path" and for multiple its bin:{ }.. this never says you to keep executables in root folder. i am saying ./bin/cli.js is similar to bin/cli.js. |
These exaples give a warning. Just try them. You will see a warning. That is the issue. If examples are not correct, they must be fixed. If warning is not correct, it must be not emitted. If there is some other problem, it must be fixed. Currently this issue is closed, but it is not fixed. Looks like nobody really followed the steps I described. |
@Santoshraj2 Please read the description of the issue and follow the steps provided there. Do you see warnings emitted? |
I clearly followed the steps, thats why we agreed that its a problem and required doc fix. But there are 2 sides of problem: In this case we got warning, but when we keep cli.js inside bin folder with package.json as "bin": {
its not giving warning and working fine keeping cli.js in bin folder and package.json has "bin": { |
The warning is there to let folks know of the changes npm has always been making to the package.json during publish. The fact that it is surprising to folks is exactly why that warning is there. The package.json in your package and the manifest in the registry differ, sometimes by a lot. This is not ideal, and we are working towards limiting those differences. The beginning of that work was to log a warning whenever what was published was different than what was on disk. So while it may seem like "./foo" and "foo" are similar, they are not. They never have been as far as npm's directory parsing is concerned. Remember we are dealing with 12 years of built up history, and not often built from a spec. If you run |
Our existing example present in npm doc was giving warning. issue: #7302
Thanks a lot for detailed explanation. I do understand this is only a minor detail, but it felt important to point out that there is a difference between actual behaviour and documentation. Apologies if my comments sounded repetitive or explanations were hard to understand. Now I get that this is a documentation issue only. Glad to see it being fixed. Thanks again for taking care. |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
npm publish
complains and auto correct thebin
field examples from npm docs.Expected Behavior
Seems like the examples are correct, there is no need to complain or alter the code.
Steps To Reproduce
First example:
npm init -y
cli.js
bin
field entry from npm docs topackage.json
:Second example:
npm init -y
cli.js
bin
field entry from npm docs topackage.json
:Finally run
npm publish --dry-run
. In both casesnpm
complains:Environment
The text was updated successfully, but these errors were encountered: