sapper icon indicating copy to clipboard operation
sapper copied to clipboard

npm run dev: Error: ENOENT: no such file or directory, open '__sapper__/build/build.json'

Open btakita opened this issue 5 years ago • 8 comments

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'

btakita avatar Apr 13 '19 09:04 btakita

npm run build is an important ritual that should be run alone :)

vladejs avatar Apr 13 '19 16:04 vladejs

+1 for allowing parallel build & dev

thgh avatar Apr 13 '19 17:04 thgh

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.

btakita avatar Jul 25 '19 19:07 btakita

How to solve this ?

brightchip avatar Aug 16 '20 02:08 brightchip

I tried with a fresh install and Sapper 0.28.1 and I'm getting this error as well 🤔 Screen Shot 2020-08-26 at 07 19 28

evdama avatar Aug 26 '20 05:08 evdama

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 avatar Aug 26 '20 05:08 maxmilton

@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

btakita avatar Sep 06 '20 16:09 btakita

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/node_modules/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. (/root/.nvm/versions/node/v12.18.3/lib/node_modules/npm/lib/config/core.js:96:5) at Conf.emit (events.js:315:20) at ConfigChain._resolve (/root/.nvm/versions/node/v12.18.3/lib/node_modules/npm/node_modules/config-chain/index.js:281:34) at ConfigChain.add (/root/.nvm/versions/node/v12.18.3/lib/node_modules/npm/node_modules/config-chain/index.js:259:10) at Conf.add (/root/.nvm/versions/node/v12.18.3/lib/node_modules/npm/lib/config/core.js:338:27) at Conf. (/root/.nvm/versions/node/v12.18.3/lib/node_modules/npm/lib/config/core.js:314:25) internal/bootstrap/switches/does_own_process_state.js:128 cachedCwd = rawMethods.cwd(); ^

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' }

yangdachaun avatar Feb 07 '21 06:02 yangdachaun