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
.
Steps to reproduce the behavior, please provide code snippets or a repository:
npm i
npm run build
or npx next build
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.
^9.3.4
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
@ijjk I'm using Node v10.10.0
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
Ok, @ijjk thanks!
Yeah, I just installed v12.16.1
and it seems to be working fine.
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
Most helpful comment
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