Skip to content

Commit a24b7de

Browse files
committed
fix(snap-test): pre-create npm global prefix directory
Tests using npm global operations (link, outdated -g, unlink) fail with ENOENT when sharded because the NPM_CONFIG_PREFIX directory was only implicitly created by whichever test ran `npm install -g` first. With sharding, that test may be in a different shard.
1 parent ef6788b commit a24b7de

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

packages/tools/src/snap-test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ export async function snapTest() {
111111
const systemTmpDir = fs.realpathSync(tmpdir());
112112
const tempTmpDir = `${systemTmpDir}/vite-plus-test-${randomUUID().replaceAll('-', '')}`;
113113
fs.mkdirSync(tempTmpDir, { recursive: true });
114+
// Pre-create the npm global prefix directory so tests using npm global
115+
// operations (link, outdated -g, etc.) don't fail with ENOENT.
116+
fs.mkdirSync(path.join(tempTmpDir, 'npm-global-lib-for-snap-tests'));
114117

115118
// Clean up stale .node-version and package.json in the system temp directory.
116119
// vite-plus walks up the directory tree to resolve Node.js versions, so leftover

0 commit comments

Comments
 (0)