Skip to content

npm causes the windows installer (.msi) to almost reach MAX_PATH (and using the .zip can easily exceed it) #19449

Closed
@TheCloudlessSky

Description

@TheCloudlessSky
  • Version: current release (9.8.0) and LTS (8.10.0)
  • Platform: Windows 7 64-bit

After installing Node 9.8.0 or 8.10.0 via the Windows Installer (.msi), the installation almost reaches the MAX_PATH allowed in Windows (260 characters). Here's the top 10 paths by length from the 8.10.0 installer:

$ cmd /c dir /S /B | Sort-Object { -$_.Length; } | Select-Object -First 10 | % { "$($_.Length) = $_" }
239 = C:\Program Files\nodejs\node_modules\npm\node_modules\libnpx\node_modules\yargs\node_modules\read-pkg-up\node_modules\read-pkg\node_modules\load-json-file\node_modules\parse-json\node_modules\error-ex\node_modules\is-arrayish\.istanbul.yml
239 = C:\Program Files\nodejs\node_modules\npm\node_modules\libnpx\node_modules\yargs\node_modules\read-pkg-up\node_modules\read-pkg\node_modules\load-json-file\node_modules\parse-json\node_modules\error-ex\node_modules\is-arrayish\.editorconfig
238 = C:\Program Files\nodejs\node_modules\npm\node_modules\npm-profile\node_modules\make-fetch-happen\node_modules\https-proxy-agent\node_modules\agent-base\node_modules\es6-promisify\node_modules\es6-promise\lib\es6-promise\promise\resolve.js
238 = C:\Program Files\nodejs\node_modules\npm\node_modules\npm-profile\node_modules\make-fetch-happen\node_modules\socks-proxy-agent\node_modules\agent-base\node_modules\es6-promisify\node_modules\es6-promise\lib\es6-promise\promise\resolve.js
238 = C:\Program Files\nodejs\node_modules\npm\node_modules\libnpx\node_modules\yargs\node_modules\read-pkg-up\node_modules\read-pkg\node_modules\load-json-file\node_modules\parse-json\node_modules\error-ex\node_modules\is-arrayish\package.json
237 = C:\Program Files\nodejs\node_modules\npm\node_modules\npm-profile\node_modules\make-fetch-happen\node_modules\socks-proxy-agent\node_modules\agent-base\node_modules\es6-promisify\node_modules\es6-promise\lib\es6-promise\promise\reject.js
237 = C:\Program Files\nodejs\node_modules\npm\node_modules\libnpx\node_modules\yargs\node_modules\read-pkg-up\node_modules\read-pkg\node_modules\load-json-file\node_modules\parse-json\node_modules\error-ex\node_modules\is-arrayish\.travis.yml
237 = C:\Program Files\nodejs\node_modules\npm\node_modules\npm-profile\node_modules\make-fetch-happen\node_modules\https-proxy-agent\node_modules\agent-base\node_modules\es6-promisify\node_modules\es6-promise\lib\es6-promise\promise\reject.js
237 = C:\Program Files\nodejs\node_modules\npm\node_modules\npm-profile\node_modules\make-fetch-happen\node_modules\http-proxy-agent\node_modules\agent-base\node_modules\es6-promisify\node_modules\es6-promise\lib\es6-promise\promise\resolve.js
236 = C:\Program Files\nodejs\node_modules\npm\node_modules\libnpx\node_modules\yargs\node_modules\read-pkg-up\node_modules\read-pkg\node_modules\load-json-file\node_modules\parse-json\node_modules\error-ex\node_modules\is-arrayish\.npmignore

I also use the .zip which can easily run into this problem if it isn't unzipped to a short enough path.

The .msi installer is very close to failing to install to C:\Program Files\nodejs if any module that npm depends on grows to a longer path. This isn't a problem when using npm since it'll properly dedupe the packages with npm > 3. This problem is with the installation of npm itself (which Node includes with its releases). Ideally, node_modules/npm would be pre-deduped so that it's not so long.

I plan to report this issue to the NPM team as well. For now, I've switched to using the standalone .exe and the yarn package manager (since it's just a single file and not a huge directory structure).

Metadata

Metadata

Assignees

No one assigned

    Labels

    npmIssues and PRs related to the npm client dependency or the npm registry.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions