Open btakita opened 5 years ago
npm run build
is an important ritual that should be run alone :)
+1 for allowing parallel build & dev
It seems like the issue is with
fs.writeFileSync(path.join(dest, 'build.json'), JSON.stringify(build_info));
https://github.com/sveltejs/sapper/blob/master/src/api/build.ts#L113
The watch process is running in parallel. If a temp file were written & then moved, via the shell, to the dest/build.json, then the operation should be atomic from an OS perspective.
The fs-write-stream-atomic write-file-atomic npm package should perform this. This project is under npm.
It looks like fs-write-stream-atomic is a dependency of Sapper.
How to solve this ?
I tried with a fresh install and Sapper 0.28.1 and I'm getting this error as well 🤔
I didn't realise this issue was already open... I've created a new issue https://github.com/sveltejs/sapper/issues/1440 with more detailed information and a repro repo. The cause behind the error now is different to when this issue was opened so maybe it's time to close this one?
@MaxMilton These appear to be separate issues. I'm still getting this (https://github.com/sveltejs/sapper/issues/627) issue with the 0.28.4 release. This issue is not a race condition. It occurs every time npm run build
is invoked when npm run dev
is already running.
To reproduce:
In console 1
npm run dev
...wait for the dev server to start...
In console 2
npm run build
root@dev-VirtualBox:/media/sf_work/ewechat# npm run dev
Error: ENOENT: no such file or directory, uv_cwd
at process.wrappedCwd (internal/bootstrap/switches/does_own_process_state.js:128:26)
at process.cwd (/root/.nvm/versions/node/v12.18.3/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:10:19)
at Conf.loadPrefix (/root/.nvm/versions/node/v12.18.3/lib/nodemodules/npm/lib/config/load-prefix.js:46:24)
at load (/root/.nvm/versions/node/v12.18.3/lib/node_modules/npm/lib/config/core.js:109:8)
at Conf.
Error: ENOENT: no such file or directory, uv_cwd at process.wrappedCwd (internal/bootstrap/switches/does_own_process_state.js:128:26) at process.cwd (/root/.nvm/versions/node/v12.18.3/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:10:19) at process.errorHandler (/root/.nvm/versions/node/v12.18.3/lib/node_modules/npm/lib/utils/error-handler.js:183:30) at process.emit (events.js:315:20) at process._fatalException (internal/process/execution.js:165:25) { errno: -2, code: 'ENOENT', syscall: 'uv_cwd' }
To reproduce, run
npm run dev
Then, while dev is running, run
npm run build
The
npm run dev
process will get the following error:Error: ENOENT: no such file or directory, open '__sapper__/build/build.json'