cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] `npm help json` errors on Windows

Open mbtools opened this issue 1 year ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

On Linux, npm help json displays correctly man/man5/npm-json.

On Windows, npm help json attempts to display the corresponding HTML page which leads to the following error:

PS C:\GitHub\npm\cli> npm help json  
npm ERR! code 1
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c start "" file:///C:^%5Cnvm^%5Cv20.11.1^%5Cnode_modules^%5Cnpm^%5Cdocs^%5Coutput^%5Cconfiguring-npm^%5Cnpm-json.html
npm ERR! The system cannot find the file file:///C:%5Cnvm%5Cv20.11.1%5Cnode_modules%5Cnpm%5Cdocs%5Coutput%5Cconfiguring-npm%5Cnpm-json.html.

npm help global has the same problem.

Expected Behavior

npm help json and npm help global should display the same documentation on Windows as on Linux

Steps To Reproduce

  1. Any Windows version, npm 8 or higher
  2. Run npm help json
  3. See error

Cause:

The build process duplicates two man pages (package-json -> npm-json, folders -> npm-global). However, it does not duplicate the html pages. Therefore, npm help json won't find any HTML version of the duplicated man pages:

https://github.com/npm/cli/blob/9622597399ec93224fddf90a9209a98dbcfd6b2f/docs/lib/build.js#L96-L118

man:

image

html:

image

Possible solution:

  • Duplicate also the HTML (might as well duplicate the Markdown)

Environment

  • npm: 10
  • Node.js: 20
  • OS Name: Windows 10

mbtools avatar Apr 14 '24 11:04 mbtools