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 publish complains on bin field examples from npm docs #7302

Open
2 tasks done
mrazauskas opened this issue Mar 20, 2024 · 2 comments
Open
2 tasks done

[BUG] npm publish complains on bin field examples from npm docs #7302

mrazauskas opened this issue Mar 20, 2024 · 2 comments
Assignees
Labels
Bug thing that needs fixing Documentation documentation related issue Priority 2 secondary priority issue Release 10.x

Comments

@mrazauskas
Copy link

mrazauskas commented Mar 20, 2024

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

npm publish complains and auto correct the bin 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:

  1. Create fresh repo with npm init -y
  2. Add dummy file cli.js
  3. Copy bin field entry from npm docs to package.json:
"bin": {
  "myapp": "./cli.js"
}

Second example:

  1. Create fresh repo with npm init -y
  2. Add dummy file cli.js
  3. Copy bin field entry from npm docs to package.json:
"bin": "./cli.js"

Finally run npm publish --dry-run. In both cases npm complains:

npm WARN publish npm auto-corrected some errors in your package.json when publishing.  Please run "npm pkg fix" to address these errors.
npm WARN publish errors corrected:
npm WARN publish "bin[myapp]" script name was cleaned

Environment

  • npm: 10.2.4
  • Node.js: 20.11.1
  • OS Name: macOS
  • System Model Name: Macbook Pro
  • npm config:
; "user" config from /Users/(replaced)/.npmrc

//registry.npmjs.org/:_authToken = (protected) 

; node bin location = /Users/(replaced)/.n/bin/node
; node version = v20.11.1
; npm local prefix = /Users/(replaced)/Projects/x-npm-bin
; npm version = 10.2.4
; cwd = /Users/(replaced)/Projects/x-npm-bin
; HOME = /Users/(replaced)
; Run `npm config ls -l` to show all defaults.
@mrazauskas mrazauskas added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Mar 20, 2024
@milaninfy milaninfy added Documentation documentation related issue Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Mar 21, 2024
@trivikr
Copy link

trivikr commented Mar 26, 2024

Related: npm/package-json#83

@Santoshraj2 Santoshraj2 self-assigned this May 9, 2024
@Santoshraj2
Copy link
Contributor

@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.

  1. create cli.js file inside bin folder
  2. make below entry in package.json file.
    "bin": {
    "myapp": "bin/cli.js"
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Documentation documentation related issue Priority 2 secondary priority issue Release 10.x
Projects
None yet
Development

No branches or pull requests

4 participants