Skip to content

Commit ff47778

Browse files
authored
fix: no permission to create vite config file (#18844)
1 parent 3ffcb18 commit ff47778

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/vite/src/node/config.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,14 +1857,23 @@ async function loadConfigFromBundledFile(
18571857
// Storing the bundled file in node_modules/ is avoided for Deno
18581858
// because Deno only supports Node.js style modules under node_modules/
18591859
// and configs with `npm:` import statements will fail when executed.
1860-
const nodeModulesDir =
1860+
let nodeModulesDir =
18611861
typeof process.versions.deno === 'string'
18621862
? undefined
18631863
: findNearestNodeModules(path.dirname(fileName))
18641864
if (nodeModulesDir) {
1865-
await fsp.mkdir(path.resolve(nodeModulesDir, '.vite-temp/'), {
1866-
recursive: true,
1867-
})
1865+
try {
1866+
await fsp.mkdir(path.resolve(nodeModulesDir, '.vite-temp/'), {
1867+
recursive: true,
1868+
})
1869+
} catch (e) {
1870+
if (e.code === 'EACCES') {
1871+
// If there is no access permission, a temporary configuration file is created by default.
1872+
nodeModulesDir = undefined
1873+
} else {
1874+
throw e
1875+
}
1876+
}
18681877
}
18691878
const hash = `timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`
18701879
const tempFileName = nodeModulesDir

0 commit comments

Comments
 (0)