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
{{ message }}
Repository navigation
'Error: No known conditions for "./node" specifier in "msw" package' when using MSW with Vitest #125
I created an mswjs/msw#2092 at msw, but they said it's a problem of the framework (i.e. solid).
I still have to try the workaround they proposed, but the reason for the error is that vite-plugin-solid sets "browser" as resolve.conditionshere.
This means that vite tries to load the browser-version of msw/node which does not exist.
According to @kettanaito it is wrong to use browser for node.js, I personally think it is debatable.
What I also noticed is that solid returns and empty render function when the resolve.conditions is set to "node". I don't really undestand why, but it seems wrong to assume that Node.js is only ever used for SSR.
So, after some more insights, my last statement is wrong. My current stance is that the package.json of mock-service-worker is not entirely correct. The resolve.conditions applied in this module actuall contains node. So it should be possible to load msw/node
There's been a ton of changes and improvements to both Vitest and MSW since this was open. I highly recommend trying to reproduce this on the latest versions of both libs. There's a very small chance it will still happen. We are testing all MSW packages in Vitest. I also know for a fast Vitest doesn't use the browser export condition unless you force it.
Activity
sanghunjlee commentedon Mar 4, 2024
Had the same issue earlier today.
For those visiting this issue searching for solution, I went around this issue by adding an
aliastoresolvein the config file:Hope that helps.
nknapp commentedon Mar 19, 2024
I created an mswjs/msw#2092 at msw, but they said it's a problem of the framework (i.e. solid).
I still have to try the workaround they proposed, but the reason for the error is that
vite-plugin-solidsets "browser" asresolve.conditionshere.This means that vite tries to load the browser-version of
msw/nodewhich does not exist.According to @kettanaito it is wrong to use
browserfor node.js, I personally think it is debatable.What I also noticed is that solid returns and empty
renderfunction when theresolve.conditionsis set to "node". I don't really undestand why, but it seems wrong to assume that Node.js is only ever used for SSR.nknapp commentedon Mar 23, 2024
So, after some more insights, my last statement is wrong. My current stance is that the package.json of mock-service-worker is not entirely correct. The
resolve.conditionsapplied in this module actuall containsnode. So it should be possible to loadmsw/nodebrenelz commentedon Sep 11, 2026
Can you retest with updated MSW/Vite/Vitest?
kettanaito commentedon Sep 14, 2026
There's been a ton of changes and improvements to both Vitest and MSW since this was open. I highly recommend trying to reproduce this on the latest versions of both libs. There's a very small chance it will still happen. We are testing all MSW packages in Vitest. I also know for a fast Vitest doesn't use the browser export condition unless you force it.