question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

File already exists error when building

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

12reactions
ijjkcommented, 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

11reactions
ijjkcommented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

File already exists error - Builds - Bitrise Discussions
Hello, I am trying to create two different Android builds (APK), by running the Gradle task on two different flavors.
Read more >
Why am I getting the error: "FileExistsError: [WinError 183 ...
I'd run this numerous times with no problem. Ran it again, and got an error: FileExistsError: [WinError 183] Cannot create a file when...
Read more >
BUILD / "File already exists" error - Foxite
I am suddenly getting a "File exists" error when I attempt to compile an application that has existed for years. I'm not sure...
Read more >
Getting "Source file already exists error" on trying ... - YouTrack
Getting "Source file already exists error" on trying to incrementally build the project that uses source generation and Eclipse compiler ; Project, IntelliJ...
Read more >
File already exists! #10520 (SL1) - Prusa Knowledge Base
Rename your file before the transfer or delete the existing file with the identical name. Was this article helpful?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found