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

File already exists error when building #11601

Closed
nicholaschiang opened this issue Apr 2, 2020 · 6 comments
Closed

File already exists error when building #11601

nicholaschiang opened this issue Apr 2, 2020 · 6 comments

Comments

@nicholaschiang
Copy link
Contributor

Bug report

Describe the bug

A clear and concise description of what the bug is.

When I run npx next build in my Next.js project, I come up with this error:

> Build error occurred
{ [Error: EEXIST: file already exists, mkdir '/home/nchiang/repos/covid-tutoring/.next']
  errno: -17,
  code: 'EEXIST',
  syscall: 'mkdir',
  path: '/home/nchiang/repos/covid-tutoring/.next' }

When I remove that .next directory, I come up with a similar error:

> next build

Creating an optimized production build ...fs.js:115
    throw err;
    ^

Error: EEXIST: file already exists, mkdir '/home/nchiang/repos/covid-tutoring/.next/cache/next-minifier'
    at mkdirSync (fs.js:731:3)
    at new TaskRunner (/home/nchiang/repos/covid-tutoring/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/TaskRunner.js:1:634)
    at TerserPlugin.optimizeFn (/home/nchiang/repos/covid-tutoring/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:6:1316)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/nchiang/repos/covid-tutoring/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:21:1)
    at AsyncSeriesHook.lazyCompileHook (/home/nchiang/repos/covid-tutoring/node_modules/tapable/lib/Hook.js:154:20)
    at hooks.additionalAssets.callAsync.err (/home/nchiang/repos/covid-tutoring/node_modules/webpack/lib/Compilation.js:1409:36)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/nchiang/repos/covid-tutoring/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/home/nchiang/repos/covid-tutoring/node_modules/tapable/lib/Hook.js:154:20)
    at hooks.optimizeTree.callAsync.err (/home/nchiang/repos/covid-tutoring/node_modules/webpack/lib/Compilation.js:1405:32)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/nchiang/repos/covid-tutoring/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! root@ build: `next build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the root@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/nchiang/.npm/_logs/2020-04-02T15_16_25_792Z-debug.log

I'm guessing that this has something to do with fs.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Clone this repository
  2. Install dependencies with npm i
  3. Run npm run build or npx next build
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Running npm run build or npx next build should build the app for production usage.

System information

  • OS: Ubuntu 18.04.2
  • Version of Next.js: ^9.3.4
@ijjk
Copy link
Member

ijjk commented Apr 2, 2020

Hi, what version of Node.js are you using where you are seeing this error? Next.js v9.3.4 requires Node.js >= 10 as mentioned in the System Requirements and using a lower version of Node.js may be the reason you are seeing this error

@nicholaschiang
Copy link
Contributor Author

@ijjk I'm using Node v10.10.0

@ijjk
Copy link
Member

ijjk commented Apr 2, 2020

Node.js v10.10.0 is just slightly under the required version and v10.13.0 is needed. Since this can cause some confusion we can make sure to specify this exact version as the minimum required version in our docs.

Note: yarn v1 can help catch these slight incompatibilities
Screen Shot 2020-04-02 at 12 46 46

@nicholaschiang
Copy link
Contributor Author

Ok, @ijjk thanks!

Yeah, I just installed v12.16.1 and it seems to be working fine.

@HugoVizcainoSantana
Copy link

HugoVizcainoSantana commented Jun 15, 2020

I'm having this same problem, but with a small quirk. It fails if i am not the one executing it. I I type manually into my shell npm run build, everything works fine, but I am trying to launch it from a script of from systemd, and I'm having no luck with it.

I have discarded it being my node version by changing to v12.16.1 and still having this problem. And I have also tried versions from 9.3.2 to 9.4.4

 Creating an optimized production build...
 fs.js:885
   return binding.mkdir(pathModule._makeLong(path),
                  ^

 Error: EEXIST: file already exists, mkdir '/var/www/sainzlab.com/.next/cache/next-minifier'
 at fs.mkdirSync (fs.js:885:18)

     at new TaskRunner (/var/www/sainzlab.com/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/TaskRunner.js:1:634)

     at TerserPlugin.optimizeFn (/var/www/sainzlab.com/node_modules/next/dist/build/webpack/plugins/terser-webpack-plugin/src/index.js:6:1316)

    at AsyncSeriesHook.eval [as callAsync] (eval at create (/var/www/sainzlab.com/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:21:1)

    at AsyncSeriesHook.lazyCompileHook (/var/www/sainzlab.com/node_modules/tapable/lib/Hook.js:154:20)

    at hooks.additionalAssets.callAsync.err (/var/www/sainzlab.com/node_modules/webpack/lib/Compilation.js:1409:36)

     at AsyncSeriesHook.eval [as callAsync] (eval at create (/var/www/sainzlab.com/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)

     at AsyncSeriesHook.lazyCompileHook (/var/www/sainzlab.com/node_modules/tapable/lib/Hook.js:154:20)

    at hooks.optimizeTree.callAsync.err (/var/www/sainzlab.com/node_modules/webpack/lib/Compilation.js:1405:32)

    at AsyncSeriesHook.eval [as callAsync] (eval at create (/var/www/sainzlab.com/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)

   npm ERR! code ELIFECYCLE

   npm ERR! errno 1

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants