Nvm-windows: nvm install fails with "The filename or extension is too long"

Created on 21 Jul 2017  ·  25Comments  ·  Source: coreybutler/nvm-windows

My Environment

Windows 8

I'm using NVM4W version:

1.1.5

My issue is related to (check only those which apply):

  • [ ] settings.txt
  • [ ] proxy support (Have you tried version 1.1.0+?)
  • [ ] 32 or 64 bit support (Have you tried version 1.1.3+?)
  • [ ] Character escaping (Have you tried version 1.1.6+?)
  • [x] A standard shell environment (terminal/powershell)
  • [ ] A non-standard shell environment (Cmder, Hyper, Cygwin, git)

Expected Behavior

Install node version 8.2.1

Actual Behavior

Fails with error The filename or extension is too long

Steps to reproduce the problem:

λ nvm install 8.2.1
Downloading node.js version 8.2.1 (64-bit)...
Complete
Downloading npm version 5.3.0... Complete
Installing npm v5.3.0...2017/07/21 09:02:31 mkdir C:\Users\suhas.karanth.RB\AppData\Roaming\nvm\temp\nvm-npm\npm-5.3.0\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: The filename or extension is too long.

While this _is_ an issue, I doubt there is a direct way to fix it. However, creating this issue to share how I got around it and how maybe it could be avoided.

I installed the latest pre-release version of nvm(v1.1.6) but this time installed it to C:\nvm\ to conserve path length. Was able to successfully install node v8.2.1 after this. Do you think it makes sense to install nvm to this path by default?

upstream-bug

Most helpful comment

If you install latest (1.1.6) and instead of C:/Users/<username>/AppData/Roaming/nvm you select C:/nvm as the installation folder, it should work. I had no problem installing 8.4.0 :)

For me, using nvm root to change the path of nvm did not work, I got weird error messages. It did not copy nvm <commands> and then even node stopped working.

Manually cloning npm as @michaelkdh suggested did also not work, and seems hackish compared to a clean installation

All 25 comments

Something is off about this installation... Did you have two versions of NVM installed at the same time by any chance?

It may be too late at this point, but what does echo %NVM_SYMLINK% output?

No. I did not have 2 versions of NVM installed at the time when the error occurred.

It may be too late at this point, but what does echo %NVM_SYMLINK% output?

Actually, not too late. I had a terminal open which still had the older environment.

λ where nvm
C:\Users\suhas.karanth.RB\AppData\Roaming\nvm\nvm.exe

λ echo %NVM_SYMLINK%
C:\Program Files\nodejs

Additionally, I had installed and was using multiple versions of node through NVM before:

λ nvm list

  * 8.1.2 (Currently using 64-bit executable)
    8.1.1
    8.1.0
    8.0.0
    6.10.3
    6.10.0
    5.12.0
    4.8.0
    4.2.6

I am having the same issue.
Windows 10
Cmder shell
NVM 1.1.5

This is occurring with node 8.2.0 and 8.2.1
8.1.4 and 8.1.3 are working fine.

$ nvm install 8.2.0
Downloading node.js version 8.2.0 (64-bit)...
Complete
Downloading npm version 5.3.0... Complete
Installing npm v5.3.0...2017/07/22 00:15:41 mkdir C:\Users\Christopher\AppData\Roaming\nvm\temp\nvm-npm\npm-5.3.0\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: The filename or extension is too long.

I wonder if we should take this up with npm upstream..
@clowenhg If you install nvm directly to C:\nvm, the issue will be resolved but your existing node installations will not longer be recognised. I had moved the multiple node folders to C:\nvm and was able to see them listed but never got a chance to test any of it out. Thanks to windows update and boot loop.

That would probably work, but just seems like a temporary work around until the next thing wants to go one more directory deep. So yea, raising this as an issue for NPM would probably be a good call.

Seeing as 8 isn't at it's final LTS version yet, I'm just reverting to 8.1.4 for now.

There do appear to be a number of issues with the new versions of npm, specifically those that include npx support. I've added support for npx in the master branch and will release it when 1.1.6 becomes official (currently being tested). However; even in that branch, npx still fails (it also fails through the standalone windows Node installer without NVM4W).

I believe this is an npm issue, not an NVM4W issue. I'm closing the issue and marking it as an upstream-issue.

@coreybutler A small clarification if you don't mind. Why did you have to make changes for npx support? Even with node v8.1, npx was available and usable, although buggy on windows. But nvm shouldn't have to do anything for this.

Node 8.1 did _not_ ship with npx support. If you have it in 8.1, you must have run npm install -g npm somewhere along the line to upgrade npm. The npx command was added in npm v5.3.0, and the first version of Node to ship with npm 5.3.0 was 8.2.1. For specific details, see #288.

Yea.. You are probably right. I do remember upgrading npm.

I had the same issue, the solution i have is to:

  1. install 8.2.1, which will fail you, that's fine.
  2. install v6.11.2 and copy 2 files (npm and npm.cmd ) from /c:/[username]/AppData/Roaming/nvm/v6.11.2 to folder v8.2.1
  3. in folder v8.2.1, do git clone https://github.com/npm/npm.git

then you should be good

Thank you @michaelkdh It works for me. 👍
Slightly different thing was that when I cloned the 'npm.git' it created 'npm' folder. And I had to move the 'npm' folder to 'node_modules'.

@gblue1223 same thing, just need npm in place. cheers,

@coreybutler According to the issue you linked you can override the paths to install to.

If you install latest (1.1.6) and instead of C:/Users/<username>/AppData/Roaming/nvm you select C:/nvm as the installation folder, it should work. I had no problem installing 8.4.0 :)

For me, using nvm root to change the path of nvm did not work, I got weird error messages. It did not copy nvm <commands> and then even node stopped working.

Manually cloning npm as @michaelkdh suggested did also not work, and seems hackish compared to a clean installation

@peterbakonyi05 It's still hackish to redefine the nvm folder just to install it too.

@Sieabah I agree, the whole problem is weird. However I think it is still better than the other 2 proposed solutions (actually none of them worked for me)

For those still running into this, could someone provide steps for recreating this error? Or perhaps a screencast? I have yet to actually see this in action.

Also, I've noticed alot of people are copy/pasting from their terminals... and the syntax like /c/whatever, lambdas, etc keep showing up.... all of which indicate people are using things like Cygwin, git shells, cmder, etc. Please note that these shells _do not always adhere to the Windows platform standards_, and they _do_ affect how paths are read. There are several other issues citing this, so try everything in a standard terminal before posting to make sure it's an NVM4W issue and not a terminal-shell issue.

@coreybutler Here you go, with cmd.exe

C:\Users\Christopher>nvm install 8.4.0
Downloading node.js version 8.4.0 (64-bit)...
Complete
Creating C:\Users\Christopher\AppDataRoamingnvm\temp

Downloading npm version 5.3.0... Complete
Installing npm v5.3.0...2017/09/05 16:50:14 mkdir C:\Users\Christopher\AppDataRoamingnvm\tempnvm-npmnpm-5.3.0node_modules\libnpxnode_modules\yargsnode_modules\read-pkg-upnode_modules\read-pkgnode_modules\load-json-filenode_modules\parse-jsonnode_modules\error-exnode_modules\is-arrayish: The filename or extension is too long.

C:\Users\Christopher>where nvm
C:\Users\Christopher\AppDataRoamingnvmnvm.exe

C:\Users\Christopher>nvm install 8.4.0
Downloading node.js version 8.4.0 (64-bit)...
Complete
Creating C:\Users\Christopher\AppDataRoamingnvm\temp

Downloading npm version 5.3.0... Complete
Installing npm v5.3.0...2017/09/05 16:50:14 mkdir C:\Users\Christopher\AppDataRoamingnvm\tempnvm-npmnpm-5.3.0node_modules\libnpxnode_modules\yargsnode_modules\read-pkg-upnode_modules\read-pkgnode_modules\load-json-filenode_modules\parse-jsonnode_modules\error-exnode_modules\is-arrayish: The filename or extension is too long.

C:\Users\Christopher>where node
C:\Program Filesnodejsnode.exe

C:\Users\Christopher>where npm
C:\Program Filesnodejsnpm
C:\Program Filesnodejsnpm.cmd

I'm also on nvm version 1.1.5 if that makes a difference (maybe you're on 1.1.6?)

I can confirm that the upgrade to 1.1.6 fixes this issue. Makes sense since it looks like some of the filepath management now uses native Go libraries.

That would also mean that the filepath bug was within nvm rather than npm itself. Any bug filed over at npm might want to be looked over again.

Thanks @computerquip-streamlabs. I got this problem and solved by upgrading nvm with,

scoop install [email protected]

And then I could install node 8.7.0 with nvm.

Installing nvm 1.1.6 fix bug with "npm installing: The filename or extension is too long"

From: C:\Users\[username]\AppDataRoamingnvm

  1. Change file settings.txt
root: C:\nvm 
path: C:\Program Files\nodejs 
arch: 64 
proxy: none
  1. Copy two files elevate.cmd and elevate.vbs to: C:nvm

Then it worked for me!

Reopening since several users are still running into this.

FWIW, I'm running Windows 10, I did enable long file paths, but still couldn't install node versions above 6.x... because of the issue with long file path in npm v 5.6, upgrading to nvm 1.1.6 fixed the issue for me.

Was this page helpful?
0 / 5 - 0 ratings