21

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
  • 907
  • 1
  • 11
  • 25

12 Answers12

11

For me, just adding --force solved it.

Al.G.
  • 4,327
  • 6
  • 31
  • 56
Awad Haj
  • 579
  • 7
  • 17
10

In my case remove white space from folder name.

shubham
  • 119
  • 1
  • 2
  • 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
  • I downvoted because: This is more like a workaround. You can not always use arbitrary foldernames (means: foldernames without white-spaces). I agree with Ruben Szeker. So this answer is not always applicable. – anion Feb 02 '23 at 12:00
  • @anion This is a node setup limitation and if you are using it on Windows you have to account on that. Maybe you don't like the npm issue, but Shubham answer is helpful to deal with it while npm developers solves it. – JoeCool Jul 05 '23 at 18:40
10

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,790
  • 9
  • 47
  • 85
  • 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

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
  • 37,072
  • 9
  • 60
  • 86
4

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

Maharramoff
  • 941
  • 8
  • 15
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,465
  • 4
  • 16
  • 22
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://learn.microsoft.com/en-US/troubleshoot/windows-client/user-profiles-and-logon/renaming-user-account-not-change-profile-path

Pridkett
  • 4,883
  • 4
  • 30
  • 47
Sir XtC
  • 166
  • 1
  • 9
  • 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
  • 432
  • 1
  • 6
  • 14
  • Useful only if you have an Apple. Those who prefer Pear will not get any help from this answer. – JoeCool Feb 09 '23 at 16:38
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.

  • 1
    is is possbile for this to happend for somone didn't used or installed Cypress? – phoenixstudio Dec 08 '20 at 13:09
  • Don't insist @phoenixstudio, this is the same answer written by bhumil raval, but these guys don't care what's on the thread. They flood all questions without a comprehensive reading in search of votes. That's the only sense of their answers. – JoeCool Feb 09 '23 at 16:47
0

In my case. edid like below

enter image description here

※one more, check white space from folder name.

cng.buff
  • 405
  • 4
  • 5
0

Its problem because you need delete ".npmrc" file.

For MacOS:

To delete the .npmrc file from the terminal on macOS, you can use the rm command. Follow these steps:

cd ~

then:

rm .npmrc

For me working.

Isabella Monza
  • 161
  • 1
  • 9