17

I'm just new to node and npm and this is frustrating.

Well it's almost all said in the title. On a Windows 10 x64 using a NON elevated prompt, all npm commands shows:

EEXIST: file already exists, mkdir 'c:\Users\Josep\AppData\Roaming\npm'
at Error (native)

Even npm -v shows it twice before the version number.

Not hapening in an elevated prompt. version numbers differ in an elevated and a user prompt.

Double checked PATH variable. Same on two cmd windows.

Node version 6.10.0

NPM Versions: 4.3.0 at elevated prompt and 3.10.10 at a user prompt.

JoeCool
  • 810
  • 1
  • 9
  • 24

10 Answers10

8

In my case remove white space from folder name.

shubham
  • 91
  • 1
  • 1
  • 1
    Can't understand why should someone downvote this answer. Should not this help nobody? Really? – JoeCool Feb 20 '20 at 19:47
  • 1
    This answer was like a miracle to me! – Darshan Jain Nov 25 '20 at 09:56
  • 1
    What if it's the \Users\Username with space\ folder though? Do I really have to change my username on windows to work with `npm`? I haven't had this issue before. Only now when I start using `npx` – Ruben Szekér Jan 02 '22 at 15:25
7

I had similar issue, solved it by removing .npmrc file, located at c:\Users\<USER>\ location.

I believe it was caused by running earlier npm config set in wrong location.

Kudos to this comments thread.

lukaszkups
  • 5,395
  • 9
  • 48
  • 78
  • 1
    This is the answer for me. I had changed my path to include a common global npm location under System32 to accommodate a service account installing NPM. Because I had an npmrc, it was throwing this error. – Kurt Johnson Jun 01 '21 at 20:35
6

For me, just adding --force solved it.

Al.G.
  • 4,175
  • 6
  • 34
  • 55
Awad Haj
  • 481
  • 7
  • 15
  • 4
    That's playing with fire – Caveman Nov 03 '20 at 16:49
  • 1
    On my installation I have node_modules as a symbolic link and I was using yarn for most of the packages, but had to use npm for one package. Setting --prefix doesn't work either, but --force seems to work on symlinks. – PHZ.fi-Pharazon Aug 07 '21 at 07:52
5

Try reinstalling node and npm for the non-admin account. If that's not an option, you can use the portable version:

Download from http://nodejs.org/dist/
Extract the archive.
Open cmd and cd to the extracted folder.
Run nodevars.bat.

It will set PATH and other things so you can now use node from this folder.

mihai
  • 34,869
  • 8
  • 56
  • 81
4

this is because you have same file in node_modules/Cypress/bin and node_modules/.bin, which is cypress(type=file).

Remove cypress(type=file) from node_modules/.bin, this will resolve the issue.

myeongkil kim
  • 2,268
  • 4
  • 14
  • 20
3

I also had this problem. Just delete npm folder, it will be created again. This problem is due to user privileges.

Maharramoff
  • 785
  • 7
  • 15
2

it happened to me, I had a space in my folders path C:\Users\Jhon Doe, should be C:\Users\JhonDoe.

Microsoft has a bit more information about how this can happen: https://docs.microsoft.com/en-US/troubleshoot/windows-client/user-profiles-and-logon/renaming-user-account-not-change-profile-path

Pridkett
  • 3,963
  • 4
  • 29
  • 47
Sir XtC
  • 81
  • 6
  • 1
    Thanks for your link! It helps not only on this issue, but on many others where the user name and the profile path are involved! – JoeCool Feb 20 '21 at 13:36
  • the easiest way to fix it, to be honest, is just creating a new account within your pc and just name it with one name or word, which will prevent a lot of headaches. – Sir XtC Mar 25 '21 at 15:11
1

For me, cd ios && pod install && cd .. fixed it.

John Harding
  • 441
  • 6
  • 13
1

I had the same issue and was able to resolve it on Windows by running the cmd prompt as Admin.

Dan Hoeger
  • 11
  • 1
1

Go to the folder where you have installed Cypress. For example D:\cypressautomation --> then go to "node_modules" --> and then ".bin" folder. Here in this folder, if there is any file named "cypress", then just delete it (before deleting I think cypress needs to be closed). Reopen the cypress. This worked perfectly fine for me.