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

nvm install fails with "The filename or extension is too long" #289

Open
1 of 6 tasks
sudo-suhas opened this issue Jul 21, 2017 · 25 comments
Open
1 of 6 tasks

nvm install fails with "The filename or extension is too long" #289

sudo-suhas opened this issue Jul 21, 2017 · 25 comments

Comments

@sudo-suhas
Copy link

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+?)
  • 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?

@coreybutler
Copy link
Owner

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?

@sudo-suhas
Copy link
Author

sudo-suhas commented Jul 21, 2017

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

@clowenhg
Copy link

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.

@sudo-suhas
Copy link
Author

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.

@clowenhg
Copy link

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.

@coreybutler
Copy link
Owner

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.

@sudo-suhas
Copy link
Author

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

@coreybutler
Copy link
Owner

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.

@sudo-suhas
Copy link
Author

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

@michaelkdh
Copy link

michaelkdh commented Aug 8, 2017

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

@gblue1223
Copy link

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

@michaelkdh
Copy link

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

@Sieabah
Copy link

Sieabah commented Sep 1, 2017

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

@peterbakonyi05
Copy link

peterbakonyi05 commented Sep 3, 2017

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

@Sieabah
Copy link

Sieabah commented Sep 5, 2017

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

@peterbakonyi05
Copy link

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

@coreybutler
Copy link
Owner

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.

@Sieabah
Copy link

Sieabah commented Sep 5, 2017

@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\AppData\Roaming\nvm\temp

Downloading npm version 5.3.0... Complete
Installing npm v5.3.0...2017/09/05 16:50:14 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.

C:\Users\Christopher>where nvm
C:\Users\Christopher\AppData\Roaming\nvm\nvm.exe

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

Downloading npm version 5.3.0... Complete
Installing npm v5.3.0...2017/09/05 16:50:14 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.

C:\Users\Christopher>where node
C:\Program Files\nodejs\node.exe

C:\Users\Christopher>where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd

@Sieabah
Copy link

Sieabah commented Sep 5, 2017

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

@computerquip-streamlabs

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.

@michaeleekk
Copy link

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

scoop install nvm@1.1.6

And then I could install node 8.7.0 with nvm.

@archimed3s
Copy link

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

@vunb
Copy link

vunb commented Nov 22, 2017

From: C:\Users\[username]\AppData\Roaming\nvm

  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!

@coreybutler coreybutler reopened this Feb 24, 2018
@coreybutler
Copy link
Owner

Reopening since several users are still running into this.

@juliemturner
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests