Skip to content

[BUG] npm help json errors on Windows #7374

@mbtools

Description

@mbtools

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

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:

cli/docs/lib/build.js

Lines 96 to 118 in 9622597

if (data.section) {
const manSrc = applyTransforms(transformedSrc, [
transform.helpLinks,
transform.man,
])
const manPaths = [
name,
fullName === 'configuring-npm/package-json' && 'npm-json',
fullName === 'configuring-npm/folders' && 'npm-global',
].filter(Boolean).map(p => applyTransforms(p, [transform.manPath]))
acc.man.push(...manPaths.map((manPath) => ({
path: manPath,
fullPath: join(man, manPath),
src: manSrc,
})))
}
acc.html.push({
path: `${fullName}.html`,
fullPath: join(html, `${fullName}.html`),
src: applyTransforms(transformedSrc, [transform.html]),
})

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions