Skip to content

Commit 8b492f4

Browse files
authored
fix: set YARN_NODE_LINKER=node-modules for yarn dlx commands (#1128)
* fix: set YARN_NODE_LINKER=node-modules for yarn dlx commands Yarn PnP mode fails when packages have undeclared dependencies (e.g. @coana-tech/cli accessing @babel/types). Setting the YARN_NODE_LINKER env var to node-modules forces traditional node_modules resolution, avoiding PnP strict dependency errors. * chore: bump version to 1.1.76
1 parent 5e9e01d commit 8b492f4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "socket",
3-
"version": "1.1.75",
3+
"version": "1.1.76",
44
"description": "CLI for Socket.dev",
55
"homepage": "https://github.com/SocketDev/socket-cli",
66
"license": "MIT AND OFL-1.1",

src/utils/dlx.mts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ export async function spawnDlx(
147147
}
148148
spawnArgs.push(packageString, ...args)
149149

150+
// Use node-modules linker instead of PnP to avoid issues with packages
151+
// that have undeclared dependencies (e.g. @coana-tech/cli -> @babel/types).
152+
finalShadowOptions = {
153+
...finalShadowOptions,
154+
env: {
155+
...getOwn(finalShadowOptions, 'env'),
156+
YARN_NODE_LINKER: 'node-modules',
157+
},
158+
}
159+
150160
const shadowYarnBin = /*@__PURE__*/ require(constants.shadowYarnBinPath)
151161
return await shadowYarnBin(spawnArgs, finalShadowOptions, spawnExtra)
152162
} else {

0 commit comments

Comments
 (0)