You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The most recent update of SvelteKit can not be installed on my project because of my use of fs.readFileSync and relative paths inside of svelte.config.js.
It seems like the added lifecycle hook executes the code of svelte.config.js inside of node_modules/@sveltejs/kit (according to process.cwd()), which of course breaks any relative paths and finally makes fs.readFileSync throw, which in turn makes npm update or npm install fail and not change anything.
I use a JSON file to populate the content of config.kit.prerender.entries, so accessing a file using Nodes fs is crucial.
we've got some logic for looking for the svelte.config.js file in a different place depending on whether we're in a postinstall event or not. Presumably we could process.chdir() here rather than simply loading the config file from the appropriate directory.
That doesn't appear to quite work. I'm guessing the CWD needs to be changed back afterwards. edit: Maybe I was just running into something weird with linking packages?
Also, for the record, you repro is trying to load "./.svelte.config.js" rather than "./svelte.config.js".
Describe the bug
The most recent update of SvelteKit can not be installed on my project because of my use of
fs.readFileSync
and relative paths inside ofsvelte.config.js
.It seems like the added lifecycle hook executes the code of
svelte.config.js
inside ofnode_modules/@sveltejs/kit
(according toprocess.cwd()
), which of course breaks any relative paths and finally makesfs.readFileSync
throw, which in turn makesnpm update
ornpm install
fail and not change anything.I use a JSON file to populate the content of
config.kit.prerender.entries
, so accessing a file using Nodesfs
is crucial.Reproduction
🎩 Repository for reproduction
I quickly made a skeleton project using
npm create svelte@latest
and added the following four lines to the top ofsvelte.config.js
:https://github.com/martinszar/sveltekit-lifecycle-pwd-reproduction/blob/main/svelte.config.js#L1-L4
To observe the bug just clone the repo and run
npm install
. I additionally added aconsole.log
marked with the 🚨 emoji, which will logprocess.cwd()
.Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: