27

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.

12 Answers 12

11

For me, just adding --force solved it.

4
  • 10
    That's playing with fire
    – Caveman
    Nov 3, 2020 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. Aug 7, 2021 at 7:52
  • Not recommended use --force Jun 5, 2023 at 12:51
  • 1
    Like most things in life, if you have to force, you're doing something wrong. Sep 7, 2023 at 18:01
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.

1
  • 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. Jun 1, 2021 at 20:35
10

In my case remove white space from folder name.

5
  • 1
    Can't understand why should someone downvote this answer. Should not this help nobody? Really? Feb 20, 2020 at 19:47
  • 1
    This answer was like a miracle to me! Nov 25, 2020 at 9: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 Jan 2, 2022 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 2, 2023 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. Jul 5, 2023 at 18:40
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.

1
  • why exactly will this help, what "other things" are set by running nodevars.bat?
    – Todd
    Apr 17, 2020 at 13:57
5

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

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

1
  • I didn't had cypress in this project. Feb 9, 2023 at 16:36
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

2
  • 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! Feb 20, 2021 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, 2021 at 15:11
1

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

1
  • Useful only if you have an Apple. Those who prefer Pear will not get any help from this answer. Feb 9, 2023 at 16:38
1

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

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.

2
  • 1
    is is possbile for this to happend for somone didn't used or installed Cypress? Dec 8, 2020 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. Feb 9, 2023 at 16:47
0

In my case. edid like below

enter image description here

※one more, check white space from folder name.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.