drake035
drake035

Reputation: 2877

Having to create a .nuxt folder every time I compile my app

Every time I run npm run dev(that's how my team set up that project) I get this error:

ERROR EEXIST: file already exists, mkdir 'X:......\my-project\.nuxt'

I then need to do mkdir .nuxt and try again. Usually it works, sometimes it doesn't: it keeps asking me that everytime I run npm run dev and after 5 or 10 times it works. Sometimes I won't work no matter how many times I try, so I restart my machine and then it works.

Any idea what's going on?

Upvotes: 1

Views: 1209

Answers (1)

Alejandro Vales
Alejandro Vales

Reputation: 2937

I have had issues of this kind when running in the past with gulp in parallel tasks that would delete and write to the same deleted directory. But, without having more information about this, and just knowing that sometimes the .nuxt directory is missing. I can't really get to the root of the problem. It might be something related with the nuxt.config.js

This is the only solution that I see for now.

Even though this might not fix the original issue what you could do to at least be able to develop without having to worry any longer is:

  • Add the rimraf package and run it always before running the dev command.
  • Add the mkdirp package and run it after the deletion of the folder happen

If you add the commands globally now you should have in your terminal both commands available and you can run

rimraf ./.nuxt && mkdirp .nuxt && npm run dev

This would be the least intrusive approach as it wouldn't affect any of your team members.

If also they are affected by this you can also add this packages as a devDependency and add another npm run dev command as shown here.

{
...
    "scripts": {
        "dev": "rimraf ./.nuxt && mkdirp .nuxt && npm run dev"
    }
...
}

Upvotes: 2

Related Questions